Module: ActiveRecord::Store::ClassMethods
- Defined in:
- lib/active_record/store.rb
Instance Method Summary collapse
Instance Method Details
#store(store_attribute, options = {}) ⇒ Object
31 32 33 34 |
# File 'lib/active_record/store.rb', line 31 def store(store_attribute, = {}) serialize store_attribute, Hash store_accessor(store_attribute, [:accessors]) if .has_key? :accessors end |
#store_accessor(store_attribute, *keys) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_record/store.rb', line 36 def store_accessor(store_attribute, *keys) Array(keys).flatten.each do |key| define_method("#{key}=") do |value| send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash) send("#{store_attribute}_will_change!") send(store_attribute)[key] = value end define_method(key) do send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash) send(store_attribute)[key] end end end |