Module: AttributeBuilder::ClassMethods
- Defined in:
- lib/redisant/attribute_builder.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/redisant/attribute_builder.rb', line 7 def attribute name, ={} attributes[name.to_s] = if [:index] index name, type: [:index] # add index for attribute end if [:search] || [:unique] finder name, type: [:search] # add search for attribute end send :define_method, name.to_s do attribute(name.to_s) end send :define_method, "#{name.to_s}=" do |value| set_attribute(name.to_s, value) end end |
#attributes ⇒ Object
32 33 34 |
# File 'lib/redisant/attribute_builder.rb', line 32 def attributes @attributes ||= {} end |
#find_attribute(name) ⇒ Object
28 29 30 |
# File 'lib/redisant/attribute_builder.rb', line 28 def find_attribute name indexes[name.to_s] end |