Method: StorageRoom::Accessors::ClassMethods#define_attribute_methods

Defined in:
lib/storage_room/accessors.rb

#define_attribute_methods(name, options) ⇒ Object

Creates getter and setter for an attribute



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/storage_room/accessors.rb', line 72

def define_attribute_methods(name, options) # :nodoc:
  define_method name do
    attributes[name] || options[:default]
  end

  define_method "#{name}=" do |object|
    attributes[name] = object
  end

  self.attribute_options[name] = options
end