Skip to content

Commit 950cfb4

Browse files
committed
use github links in gemfile for now, due to unreleased code
1 parent 8bda6a7 commit 950cfb4

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ eval_gemfile local_gemfile if File.readable?(local_gemfile)
77
# Specify your gem's dependencies in active_model_serializers.gemspec
88
gemspec
99

10+
gem 'jsonapi-deserializable', github: 'beauby/jsonapi-deserializable'
11+
gem 'jsonapi-validations', github: 'beauby/jsonapi-validations'
12+
gem 'jsonapi', github: 'beauby/jsonapi'
13+
1014
version = ENV['RAILS_VERSION'] || '4.2'
1115

1216
if version == 'master'

lib/active_model_serializers/adapter/json_api/deserialization.rb

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'jsonapi'
2+
require 'jsonapi/deserializable'
23

34
module ActiveModelSerializers
45
module Adapter
@@ -83,24 +84,26 @@ def parse!(document, options = {})
8384
def parse(document, options = {})
8485
JSONAPI.parse_response!(document)
8586
document = document.to_h
86-
primary_data = document['data']
87-
88-
# null data is allowed, as per the JSON API Schema
89-
return {} unless primary_data
90-
91-
attributes = primary_data['attributes'] || {}
92-
attributes['id'] = primary_data['id'] if primary_data['id']
93-
relationships = primary_data['relationships'] || {}
94-
95-
filter_fields(attributes, options)
96-
filter_fields(relationships, options)
97-
98-
hash = {}
99-
hash.merge!(parse_attributes(attributes, options))
100-
hash.merge!(parse_relationships(relationships, options))
101-
102-
hash
103-
87+
puts document
88+
return JSONAPI::Deserializable::Resource.new(document, options)
89+
#
90+
# primary_data = document['data']
91+
#
92+
# # null data is allowed, as per the JSON API Schema
93+
# return {} unless primary_data
94+
#
95+
# attributes = primary_data['attributes'] || {}
96+
# attributes['id'] = primary_data['id'] if primary_data['id']
97+
# relationships = primary_data['relationships'] || {}
98+
#
99+
# filter_fields(attributes, options)
100+
# filter_fields(relationships, options)
101+
#
102+
# hash = {}
103+
# hash.merge!(parse_attributes(attributes, options))
104+
# hash.merge!(parse_relationships(relationships, options))
105+
#
106+
# hash
104107
rescue JSONAPI::Parser::InvalidDocument => e
105108
puts e.message
106109
return {} unless block_given?

0 commit comments

Comments
 (0)