module Face

Public Class Methods

new(hash) click to toggle source
# File lib/face/base.rb, line 3
def initialize(hash)
  hash.each do |k, v|

    # create and initialize an instance variable for this key/value pair
    self.instance_variable_set("@#{k}", v)

    # create the getter that returns the instance variable
    self.class.send(:define_method, k, proc { self.instance_variable_get("@#{k}") })

    # create the setter that sets the instance variable
    self.class.send(:define_method, "#{k}=", proc { |v| self.instance_variable_set("@#{k}", v) })
  end
end