motion-json-api 0.0.5 → 0.0.6

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: 7cd899f2086a06cc4c985b5b91e6284cf990b230
4
- data.tar.gz: 723dd9777eda173951bf011f28e8cfd310d3f7d9
3
+ metadata.gz: 0a5d7906763025f799597eb97a2b7f543ce9888e
4
+ data.tar.gz: f8fa53dc637bb00bb6b9af5fa8211380b793b66d
5
5
  SHA512:
6
- metadata.gz: 4c129d55efaf7257cfa16827d022c86d333deee318913f099256ab194f440591d6d6b5f2f7c3fcbd38d116792f7231e82144e22fdd08493199c738ace6e4386c
7
- data.tar.gz: 93f30105c966a485ab672f8199eaae4427cc5cb2f40ad234d55f12fa614278b08fd35a3769efafc99a927ccdf1a766f910a0e4fd74e7f07bbdf7657ac72410ab
6
+ metadata.gz: 056024d385cfb90f46e8dad04a6408deaa0702fb3805fee477369fdf00a474f994d1eec576fc229d543520098d1c92288dc5bd894e4f707c36bc7605555f688d
7
+ data.tar.gz: 36a98c1fc2c5acda46dbf948410b217cc874f8be7703c9392e87f86a6d73e61cc5f1edf692e466668a2d5ea4a5ba69135369a5482b273598d371e44eedef6f42
data/README.md CHANGED
@@ -59,6 +59,12 @@ resource.meta
59
59
  resource.user.links
60
60
  ```
61
61
 
62
+ If the answer is an array, you will get a `Resources` object, which has at the moment
63
+ two attributes:
64
+
65
+ - data (an array of `Resource`)
66
+ - links
67
+
62
68
  ## Run tests
63
69
 
64
70
  ```
@@ -8,4 +8,5 @@ else
8
8
  require 'motion-json-api/exceptions'
9
9
  require 'motion-json-api/descendants'
10
10
  require 'motion-json-api/resource'
11
+ require 'motion-json-api/resources'
11
12
  end
@@ -101,10 +101,7 @@ module MotionJsonApi
101
101
  top_level = [top_level].flatten
102
102
  case object["data"]
103
103
  when Array
104
- return object["data"].map do |data|
105
- resource_klass = Resource._klass_for_type(data["type"])
106
- resource_klass.new({"data" => data}, top_level, included)
107
- end
104
+ return Resources.new(object, top_level, included)
108
105
  when Hash
109
106
  resource_klass = Resource._klass_for_type(object["data"]["type"])
110
107
  resource_klass.new(object, top_level, included)
@@ -0,0 +1,14 @@
1
+ module MotionJsonApi
2
+ class Resources
3
+ attr_accessor :links
4
+ attr_accessor :data
5
+
6
+ def initialize(object, top_level, included)
7
+ @links = object.fetch("links", {})
8
+ @data = object["data"].map do |data|
9
+ resource_klass = Resource._klass_for_type(data["type"])
10
+ resource_klass.new({"data" => data}, top_level, included)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module MotionJsonApi
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-json-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joffrey Jaffeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,7 @@ files:
66
66
  - lib/motion-json-api/descendants.rb
67
67
  - lib/motion-json-api/exceptions.rb
68
68
  - lib/motion-json-api/resource.rb
69
+ - lib/motion-json-api/resources.rb
69
70
  - lib/motion-json-api/version.rb
70
71
  homepage: https://github.com/jjaffeux/motion-json-api
71
72
  licenses: