Module: ArDocStore::EmbeddableModel::ClassMethods
- Defined in:
- lib/ar_doc_store/embeddable_model.rb
Instance Method Summary collapse
- #build(attrs = HashWithIndifferentAccess.new) ⇒ Object
-
#store_accessor(store, key) ⇒ Object
:nodoc:.
Instance Method Details
#build(attrs = HashWithIndifferentAccess.new) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/ar_doc_store/embeddable_model.rb', line 113 def build(attrs=HashWithIndifferentAccess.new) if attrs.is_a?(self.class) attrs else instance = allocate instance.instantiate attrs end end |
#store_accessor(store, key) ⇒ Object
:nodoc:
105 106 107 108 109 110 111 |
# File 'lib/ar_doc_store/embeddable_model.rb', line 105 def store_accessor(store, key) self.virtual_attributes ||= HashWithIndifferentAccess.new self.virtual_attributes = virtual_attributes.merge key => true key = key.to_sym define_method key, -> { read_store_attribute(json_column, key) } define_method "#{key}=".to_sym, -> (value) { write_store_attribute json_column, key, value } end |