Module: Redis::ORM::Attributes::ClassMethods

Defined in:
lib/redis/orm/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(key, default_value = nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/redis/orm/attributes.rb', line 48

def attribute(key, default_value = nil)
  model_attributes.merge!({key => default_value})

  define_method key do
    attributes[key]
  end

  define_method "#{key}=" do |value|
    if value != attributes[key]
      attributes[key] = value
    else
      value
    end
  end
end

#attribute_namesObject



44
45
46
# File 'lib/redis/orm/attributes.rb', line 44

def attribute_names
  model_attributes.keys
end