Merb

M

Mike Mickey

Hi I'm writing a class in /lib,
I would like the class accessing the "request" object

have you an idea ?

Thx
 
P

Phlip

Mike said:
Hi I'm writing a class in /lib,
I would like the class accessing the "request" object

have you an idea ?

Don't. If it accesses that, it's a Controller, no matter where you put it.

Now, can you pass what you need into the class in lib?

And if the class is modular (even if it has no database hooks), should it be a
model?

And do you have unit tests on it, so you can refactor it as you learn the best
role for it?

(But note that questions which are actually about Merb belong on its cheerful,
friendly, and mature mailing list...)
 
M

Mike Mickey

Now, can you pass what you need into the class in lib?

actually i need a lot of information from the request object
And if the class is modular (even if it has no database hooks), should
it be a
model?

I thought a model could not access the request ?
And do you have unit tests on it, so you can refactor it as you learn
the best
role for it?

not unit tests for it (for the moment)
 
P

Phlip

Mike said:
actually i need a lot of information from the request object

What is the class doing? I can think of things like correlating the user_agent
with the IP and the login history, to detect excessive login attempts...
I thought a model could not access the request ?

For the same reason a lib item can't see the request.

Just pass the request into your top method.
not unit tests for it (for the moment)

Write the tests first! Don't write them "last" - you will have no incentive to
get back to it.
 
M

Mike Mickey

What is the class doing? I can think of things like correlating the
user_agent
with the IP and the login history, to detect excessive login attempts...

it's an API wrapper but a lot of calls are cached in the session, so i
need to access the session in all the function of the class.

Have you a better solution ?
 
P

Phlip

Mike said:
it's an API wrapper but a lot of calls are cached in the session, so i
need to access the session in all the function of the class.

Have you a better solution ?

Better than passing the whole object in? you said you need the whole object; go
ahead and rely on OO and encapsulation. There's nothing architecturally wrong
with passing a whole object in.

The Merb mailing list might have other ideas...

news://news.gmane.org:119/gmane.comp.web.merb.devel

....but be prepared to answer the same questions as I asked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top