Module: SnFoil::JsonapiDeserializer
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/sn_foil/jsonapi_deserializer.rb
Overview
rubocop:disable Metrics/ModuleLength
Instance Attribute Summary collapse
-
#included ⇒ Object
readonly
Returns the value of attribute included.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #attribute_fields ⇒ Object
- #attribute_transforms ⇒ Object
- #attributes ⇒ Object
- #initialize(object, included: nil, **options) ⇒ Object
- #parse ⇒ Object (also: #to_h)
Instance Attribute Details
#included ⇒ Object (readonly)
Returns the value of attribute included.
34 35 36 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 34 def included @included end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
34 35 36 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 34 def object @object end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
34 35 36 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 34 def @options end |
Instance Method Details
#attribute_fields ⇒ Object
41 42 43 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 41 def attribute_fields self.class.i_attribute_fields || [] end |
#attribute_transforms ⇒ Object
45 46 47 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 45 def attribute_transforms self.class.i_attribute_transforms || {} end |
#attributes ⇒ Object
49 50 51 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 49 def attributes @attributes ||= attribute_fields | attribute_transforms.map { |k, v| v[:key] || k } end |
#initialize(object, included: nil, **options) ⇒ Object
35 36 37 38 39 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 35 def initialize(object, included: nil, **) @object = object @included = included || object[:included] @options = end |
#parse ⇒ Object Also known as: to_h
53 54 55 |
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 53 def parse parse_data end |