Method: Restforce::Mash.klass
- Defined in:
- lib/restforce/mash.rb
permalink .klass(val) ⇒ Object
When passed a hash, it will determine what class is appropriate to represent the data.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/restforce/mash.rb', line 26 def klass(val) if val.key? 'records' # When the hash has a records key, it should be considered a collection # of sobject records. Restforce::Collection elsif val.key? 'attributes' case val.dig('attributes', 'type') when "Attachment" Restforce::Attachment when "Document" Restforce::Document else # When the hash contains an attributes key, it should be considered an # sobject record Restforce::SObject end else # Fallback to a standard Restforce::Mash for everything else Restforce::Mash end end |