Module: SRL::Unmarshalable::ClassMethods
- Defined in:
- lib/srl/unmarshalable.rb
Instance Method Summary collapse
Instance Method Details
#from_hash(hash = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/srl/unmarshalable.rb', line 42 def from_hash(hash = {}) obj = new hash.each do |k, v| # Be a good boy and do not overwrite the standard ruby Object.id k = :oid if k.intern == :id next unless obj.respond_to?(k) if obj.respond_to?("#{k}=") obj.send("#{k}=", v) else obj.instance_variable_set(:"@#{k}", v) end end obj end |