Module: HashConstructed
- Included in:
- Logan::Event, Logan::Person, Logan::Project, Logan::Todo, Logan::TodoList
- Defined in:
- lib/logan/HashConstructed.rb
Overview
this module is taken from the accepted answer here stackoverflow.com/questions/1572660/is-there-a-way-to-initialize-an-object-through-a-hash
Instance Method Summary collapse
-
#initialize(h) ⇒ Object
initalizes the object by pulling key-value pairs from the hash and mapping them to the object’s instance variables.
Instance Method Details
#initialize(h) ⇒ Object
initalizes the object by pulling key-value pairs from the hash and mapping them to the object’s instance variables
10 11 12 |
# File 'lib/logan/HashConstructed.rb', line 10 def initialize(h) h.each { |k,v| send("#{k}=",v) if respond_to?("#{k}=") } end |