All, 

I have a legacy DB that use mnemonics to define state, status and flags of 
several DB objects. I'd like to cache them some way and then have each object 
have methods to return appropriate messages. Most of them are defined by a 
pattern, but not all follow the pattern. Almost all, if not all, use the same 
attributes of status, state and flags. I'd like to use a module to do this and 
then just include the module for the Models that have those attributes. 
However, I don't want to join the table at all and just get the cached values. 


My thoughts for that module would be to use method_missing and respond_to? to 
create a method that would return the mnemonic message(s) like define a method 
status_message if the model respond_to? :status. This would take the instance 
status integer value into the class's cached status mnemonic messages returning 
the message. My problem is setting up the cache. 


Most of the mnemonics follow a specific pattern, like I said, and there is a 
view that returns them all. The pattern is the object name and the attribute. 
Eg. Order would have status, flags, and state attributes and have mnemonic 
type/code/values of "ORDER_STATUSES", "ORDER_FLAGS", and "ORDER_STATES" I was 
thinking of using a class and class level variable to store them in a hash. 
But, I don't like using class level variables for numerous reasons. But, I know 
I would only hit the DB once or limit the number of times the DB is called for 
get those by maybe providing a class level method to refresh the hash. The 
mnemonics are pretty much static data, but can be changed (very, very rarely). 


Someone has to have done this type of thing before, right? 


-GregD 



-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to