ruby_json_api_client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57562295d40944d05a5a968202b18de928e2795d
|
4
|
+
data.tar.gz: 2335779d94b2e907583e702ea7c20c9f6b66562a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7919a394bebcd504e2ad00ed689bf8c85e2f25808eb4b8a77bd6ed0f6fdb7c14545328cc39b331c1e7b50208575d18c774a96d0590915e6eeeecf2ccfd4769d
|
7
|
+
data.tar.gz: ca80f7170e0f192fbcad2dcc068ee55891a283d88d2a5d373254bf804726d5c90baafb9e3e9c956cf3409d31dd909f7886b9116a0cc02a07d58f03569fdd41c8
|
@@ -20,6 +20,17 @@ module RubyJsonApiClient
|
|
20
20
|
@_fields ||= Set.new [_identifier]
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.attributes
|
24
|
+
fields.reduce({}) do |attributes, field|
|
25
|
+
attributes[field] = nil
|
26
|
+
attributes
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def attributes
|
31
|
+
@attrs ||= self.class.attributes
|
32
|
+
end
|
33
|
+
|
23
34
|
def self.has_field?(name)
|
24
35
|
fields.include?(name)
|
25
36
|
end
|
@@ -16,8 +16,17 @@ module RubyJsonApiClient
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def transformed
|
20
|
+
@transformed ||= {}
|
21
|
+
end
|
22
|
+
|
19
23
|
def transform(response)
|
20
|
-
|
24
|
+
if transformed[response].nil?
|
25
|
+
parsed = @json_parsing_method.call(response)
|
26
|
+
transformed[response] = parsed
|
27
|
+
end
|
28
|
+
|
29
|
+
transformed[response]
|
21
30
|
end
|
22
31
|
|
23
32
|
def to_data(model)
|
@@ -26,7 +35,7 @@ module RubyJsonApiClient
|
|
26
35
|
data = {}
|
27
36
|
data[key] = {}
|
28
37
|
|
29
|
-
#
|
38
|
+
# convert fields to json
|
30
39
|
model.class.fields.reduce(data[key]) do |result, field|
|
31
40
|
result[field] = model.send(field)
|
32
41
|
result
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_json_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Toronto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|