Module: NCore::Util::ClassMethods
- Defined in:
- lib/ncore/util.rb
Instance Method Summary collapse
Instance Method Details
#factory(parsed, api_creds, preload: nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ncore/util.rb', line 41 def factory(parsed, api_creds, preload: nil) if key = (parsed[:data] || parsed)[:object] discover_class(key, self).new(parsed, api_creds, preload: preload) else new(parsed, api_creds, preload: preload) end end |
#interpret_type(val_or_enum, api_creds) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ncore/util.rb', line 26 def interpret_type(val_or_enum, api_creds) case val_or_enum when Hash if key = val_or_enum[:object] discover_class(key).new({data: val_or_enum}, api_creds) else val_or_enum end when Array val_or_enum.map{|v| interpret_type v, api_creds } else val_or_enum end end |