module AttributeBuilder::ClassMethods

Public Instance Methods

attribute(name, options={}) click to toggle source
# File lib/redisant/attribute_builder.rb, line 7
def attribute name, options={}
  attributes[name.to_s] = options

  if options[:index]
    index name, type: options[:index]     # add index for attribute
  end

  if options[:search] || options[:unique]
    finder name, type: options[: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() click to toggle source
# File lib/redisant/attribute_builder.rb, line 32
def attributes
  @attributes ||= {}
end
find_attribute(name) click to toggle source
# File lib/redisant/attribute_builder.rb, line 28
def find_attribute name
  indexes[name.to_s]
end