Class: Ooor::ModelRegistry
- Inherits:
-
Object
- Object
- Ooor::ModelRegistry
- Defined in:
- lib/ooor/model_registry.rb
Instance Method Summary collapse
- #cache_key(config, model_name) ⇒ Object
- #get_template(config, model_name) ⇒ Object
- #set_template(config, model) ⇒ Object
Instance Method Details
#cache_key(config, model_name) ⇒ Object
4 5 6 7 |
# File 'lib/ooor/model_registry.rb', line 4 def cache_key(config, model_name) h = config.slice(:url, :database, :username, :scope_prefix) #sure we want username? (h.map{|k, v| v} + [model_name]).join('-') end |
#get_template(config, model_name) ⇒ Object
9 10 11 |
# File 'lib/ooor/model_registry.rb', line 9 def get_template(config, model_name) Ooor.cache.read(cache_key(config, model_name)) end |
#set_template(config, model) ⇒ Object
13 14 15 16 |
# File 'lib/ooor/model_registry.rb', line 13 def set_template(config, model) key = cache_key(config, model.openerp_model) Ooor.cache.write(key, model) end |