module Attributable

adds ability to dynamically set instance vars & accessors

Public Instance Methods

create_getter(method) click to toggle source
# File lib/arcrest/attributable.rb, line 13
def create_getter(method)
  create_method(method.to_sym) { instance_variable_get("@#{method}") }
end
create_method(name, &block) click to toggle source
# File lib/arcrest/attributable.rb, line 5
def create_method(name, &block)
  self.class.send(:define_method, name.to_sym, &block)
end
create_setter(method) click to toggle source
# File lib/arcrest/attributable.rb, line 9
def create_setter(method)
  create_method("#{method}=".to_sym) { |v| instance_variable_set("@#{method}", v) }
end
set_attr(method, value) click to toggle source
# File lib/arcrest/attributable.rb, line 17
def set_attr(method, value)
  create_setter(method)
  send "#{method}=".to_sym, value
  create_getter(method)
end