Module: VirtualAttributes::Base::Attributes::ClassMethods

Defined in:
lib/virtual-attributes/base/attributes.rb

Instance Method Summary collapse

Instance Method Details

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



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/virtual-attributes/base/attributes.rb', line 24

def column(name, options = {})
  (self.columns ||= {})[name] = {
    options:  options.with_indifferent_access
  }

  define_method name do
    read_attribute(name)
  end

  define_method :"#{name}=" do |value|
    write_attribute(name, value)
  end
end