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: 0a316d1d7a3724fcb5dc5d292aaab71e6cda9535
4
- data.tar.gz: 31cbe130cb74ed13c5a0eef4d75edc3f36ffc440
3
+ metadata.gz: 57562295d40944d05a5a968202b18de928e2795d
4
+ data.tar.gz: 2335779d94b2e907583e702ea7c20c9f6b66562a
5
5
  SHA512:
6
- metadata.gz: 701fb12f1a1260d53ad736567576f15996ff1b8e7d423519be2aae8c5998ede272fa1950a05340863f8448df3487a3be863230a367a44d35f1f813acff2268e6
7
- data.tar.gz: 89d0046c35a7477a9117e5ba4a369e901f69e0d5b7aa0cb507bc3758ef319ce63b856ec2032176f701b21418d5c5ac541d281ba5af26307d75ed0ee03ca78163
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
- @json_parsing_method.call(response)
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
- # conert fields to json
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
@@ -1,3 +1,3 @@
1
1
  module RubyJsonApiClient
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-09-26 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json