Module: KeyDial::Coercion::Structs::ClassMethods
- Defined in:
- lib/key_dial/coercion.rb
Instance Method Summary collapse
-
#from(obj, type_class = nil) ⇒ Object
Allows you to do Struct.from(obj) to instantiate a Struct using keys/values from any object intelligently.
Instance Method Details
#from(obj, type_class = nil) ⇒ Object
Allows you to do Struct.from(obj) to instantiate a Struct using keys/values from any object intelligently.
105 106 107 108 109 110 111 112 113 |
# File 'lib/key_dial/coercion.rb', line 105 def from(obj, type_class = nil) if !obj.is_a?(Struct) && !obj.is_a?(Hash) && !obj.is_a?(Array) && type_class == nil s = EMPTY.dup s[0] = obj return s else return Coercion::Structs.create(obj, type_class) end end |