restful-jsonapi 0.0.13 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/OSSMETADATA +1 -0
- data/lib/restful/jsonapi/restify_param.rb +7 -7
- data/lib/restful/jsonapi/serializable_errors.rb +5 -10
- data/lib/restful/jsonapi/version.rb +1 -1
- data/restful-jsonapi.gemspec +4 -2
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c972daf4852a92faf8f7065e643ad06a0f667e5c
|
4
|
+
data.tar.gz: bc4b308e1593f246371cd17b611395a97edc7ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3528828b80677b3c42499ce08f273c4bc102b3f2549d275d87864e0001abeccdbaaa04310e54ab95b0182b56e850ba2291ebddfe56da5315895c59daa6b7678
|
7
|
+
data.tar.gz: b22d3bee7537de9c427c639c348aa1acef628096bc7acb53242f011bb04e3fa20b36e1b38f5797265f64b391041a47a62bc4bfceb093456533352d859fd9e735
|
data/OSSMETADATA
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
osslifecycle=active
|
@@ -19,23 +19,23 @@ module Restful
|
|
19
19
|
if value.has_key? :relationships
|
20
20
|
value.delete(:relationships).each do |relationship_name, relationship_data|
|
21
21
|
new_data = restify_relationship(relationship_name, relationship_data)
|
22
|
-
new_params.merge
|
22
|
+
new_params = new_params.merge(new_data.to_h) if new_data.present?
|
23
23
|
end
|
24
24
|
end
|
25
25
|
# attributes
|
26
26
|
attributes = value.has_key?(:attributes) ? value[:attributes] : value
|
27
|
-
attributes.merge
|
27
|
+
attributes = attributes.merge(id: value[:id]) if value[:id]
|
28
28
|
attributes.transform_keys!(&:underscore)
|
29
|
-
new_params.merge
|
29
|
+
new_params = new_params.merge(attributes.to_unsafe_h)
|
30
30
|
new_params
|
31
31
|
end
|
32
32
|
|
33
33
|
def restify_relationship(relationship_name, relationship_data)
|
34
34
|
if data_is_present?(relationship_data[:data])
|
35
|
-
if relationship_data[:data].is_a?
|
36
|
-
restify_belongs_to(relationship_name, relationship_data)
|
37
|
-
else
|
35
|
+
if relationship_data[:data].is_a? Array
|
38
36
|
restify_has_many(relationship_name, relationship_data)
|
37
|
+
else
|
38
|
+
restify_belongs_to(relationship_name, relationship_data)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -45,7 +45,7 @@ module Restful
|
|
45
45
|
relationship_key = relationship_name.to_s.underscore+"_attributes"
|
46
46
|
{relationship_key => restify_data(relationship_name,relationship_data[:data])}
|
47
47
|
else
|
48
|
-
{"#{relationship_name}_id" => relationship_data[:data][:id]}
|
48
|
+
{"#{relationship_name.underscore}_id" => relationship_data[:data][:id]}
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -4,20 +4,15 @@ module Restful
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def serializable_errors(object)
|
7
|
-
errors = object.errors
|
8
7
|
prefix = object.class.to_s.demodulize.underscore
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
v.map do |msg|
|
14
|
-
{ id: "#{prefix}.#{k}", title: msg }
|
9
|
+
errors = object.errors.to_hash.each_with_object([]) do |(k, v), array|
|
10
|
+
v.each do |msg|
|
11
|
+
array.push(id: "#{prefix}.#{k}", title: msg)
|
15
12
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
json[:errors] = new_hash
|
13
|
+
end
|
19
14
|
|
20
|
-
|
15
|
+
{ errors: errors }
|
21
16
|
end
|
22
17
|
end
|
23
18
|
end
|
data/restful-jsonapi.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'restful/jsonapi/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "restful-jsonapi"
|
8
8
|
spec.version = Restful::Jsonapi::VERSION
|
9
|
-
spec.authors = ["Zach Wentz"]
|
10
|
-
spec.email = ["zwentz@netflix.com"]
|
9
|
+
spec.authors = ["Zach Wentz", "Ryan Johnston", "David Lee"]
|
10
|
+
spec.email = ["zwentz@netflix.com", "ryanj@netflix.com", "dalee@netflix.com"]
|
11
11
|
spec.summary = %q{Nice type and params for temporary JSONAPI support.}
|
12
12
|
spec.description = %q{Nice type and params for temporary JSONAPI support.}
|
13
13
|
spec.homepage = "https://github.com/Netflix/restful-jsonapi"
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "rails", "~>5.0.0"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
25
|
end
|
metadata
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful-jsonapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Wentz
|
8
|
+
- Ryan Johnston
|
9
|
+
- David Lee
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 5.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 5.0.0
|
13
29
|
- !ruby/object:Gem::Dependency
|
14
30
|
name: bundler
|
15
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,6 +57,8 @@ dependencies:
|
|
41
57
|
description: Nice type and params for temporary JSONAPI support.
|
42
58
|
email:
|
43
59
|
- zwentz@netflix.com
|
60
|
+
- ryanj@netflix.com
|
61
|
+
- dalee@netflix.com
|
44
62
|
executables: []
|
45
63
|
extensions: []
|
46
64
|
extra_rdoc_files: []
|
@@ -48,6 +66,7 @@ files:
|
|
48
66
|
- ".gitignore"
|
49
67
|
- Gemfile
|
50
68
|
- LICENSE
|
69
|
+
- OSSMETADATA
|
51
70
|
- README.md
|
52
71
|
- Rakefile
|
53
72
|
- lib/restful/jsonapi.rb
|
@@ -77,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
96
|
version: '0'
|
78
97
|
requirements: []
|
79
98
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.6.6
|
81
100
|
signing_key:
|
82
101
|
specification_version: 4
|
83
102
|
summary: Nice type and params for temporary JSONAPI support.
|