Module: WCC::Data::Mapper::Attributes::ClassMethods

Defined in:
lib/wcc/data/mapper/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(name, options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/wcc/data/mapper/attributes.rb', line 35

def attribute(name, options={})
  attributes[name.to_s] = options.freeze
  define_method(name) { self[name] }
  define_method("#{name}=") { |val| self[name] = val } if options[:writer]
end

#attributesObject



41
42
43
# File 'lib/wcc/data/mapper/attributes.rb', line 41

def attributes
  @attributes ||= {}
end

#inherited(subclass) ⇒ Object



45
46
47
48
# File 'lib/wcc/data/mapper/attributes.rb', line 45

def inherited(subclass)
  super
  subclass.instance_variable_set(:@attributes, attributes.dup)
end