Class: JSONApi::ParamsDeserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api/params_deserializer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deserialize(data) ⇒ Object



3
4
5
# File 'lib/json_api/params_deserializer.rb', line 3

def self.deserialize(data)
  self.new.deserialize(data)
end

Instance Method Details

#deserialize(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/json_api/params_deserializer.rb', line 7

def deserialize(data)
  type = sanitize_type_name(data.fetch('type'))

  attributes    = sanitize_hash(data.fetch('attributes', {}))
  relationships = data.fetch('relationships', {})

  deserialize_relationships(relationships, attributes)

  { type => attributes }
end