Module: NStore::ClassMethods
- Defined in:
- lib/nstore.rb
Overview
List of Class methods going to be included above
Instance Method Summary collapse
- #_nstore_generate_accessors(attribute, flat_accessors, prefix, stringify) ⇒ Object
- #nstore(attribute, options) ⇒ Object
Instance Method Details
#_nstore_generate_accessors(attribute, flat_accessors, prefix, stringify) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nstore.rb', line 42 def _nstore_generate_accessors(attribute, flat_accessors, prefix, stringify) flat_accessors.each do |keys| keys.map!(&:to_s) if stringify define_method("#{prefix ? "#{attribute}_" : ''}#{keys.join('_')}=".to_sym) do |value| write_nstore_attribute(attribute, keys, value) end define_method("#{prefix ? "#{attribute}_" : ''}#{keys.join('_')}".to_sym) do read_nstore_attribute(attribute, keys) end end end |
#nstore(attribute, options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nstore.rb', line 31 def nstore(attribute, ) accessors = [:accessors] prefix = .fetch(:prefix, false) stringify = .fetch(:stringify, true) flat_accessors = [] deep_flatten(accessors, [], flat_accessors) attribute = attribute.to_s if stringify _nstore_generate_accessors(attribute, flat_accessors, prefix, stringify) end |