Module: SnFoil::JsonapiDeserializer

Extended by:
ActiveSupport::Concern
Defined in:
lib/sn_foil/jsonapi_deserializer.rb

Overview

rubocop:disable Metrics/ModuleLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#includedObject (readonly)

Returns the value of attribute included.



34
35
36
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 34

def included
  @included
end

#objectObject (readonly)

Returns the value of attribute object.



34
35
36
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 34

def object
  @object
end

#optionsObject (readonly)

Returns the value of attribute options.



34
35
36
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 34

def options
  @options
end

Instance Method Details

#attribute_fieldsObject



41
42
43
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 41

def attribute_fields
  self.class.i_attribute_fields || []
end

#attribute_transformsObject



45
46
47
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 45

def attribute_transforms
  self.class.i_attribute_transforms || {}
end

#attributesObject



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, **options)
  @object = object
  @included = included || object[:included]
  @options = options
end

#parseObject Also known as: to_h



53
54
55
# File 'lib/sn_foil/jsonapi_deserializer.rb', line 53

def parse
  parse_data
end