Module: Flattery::ValueCache::ClassMethods
- Defined in:
- lib/flattery/value_cache.rb
Instance Method Summary collapse
-
#flatten_value(options = {}) ⇒ Object
Command: adds flattery definition
options
. -
#value_cache_options ⇒ Object
Returns the Flattery::ValueCache options value object.
Instance Method Details
#flatten_value(options = {}) ⇒ Object
Command: adds flattery definition options
. The options
define a single cache setting. To define multiple cache settings, call flatten_value once for each setting.
options
by example:
flatten_value :category => :name
# => will cache self.category.name to self.category_name
flatten_value :category => :name, :as => 'cat_name'
# => will cache self.category.name to self.cat_name
When explicitly passed nil, it clears all existing settings
21 22 23 |
# File 'lib/flattery/value_cache.rb', line 21 def flatten_value(={}) self..add_setting() end |
#value_cache_options ⇒ Object
Returns the Flattery::ValueCache options value object. It will inherit settings from a parent class if a model hierarchy has been defined
27 28 29 30 31 32 33 34 35 |
# File 'lib/flattery/value_cache.rb', line 27 def @value_cache_options ||= if superclass.respond_to?(:value_cache_options) my_settings = Settings.new(self) my_settings.raw_settings = superclass..raw_settings.dup my_settings else Settings.new(self) end end |