restify 0.1.2.1.b28 → 0.1.2.1.b32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/restify/relations.rb +3 -3
- data/lib/restify/resource.rb +5 -9
- data/spec/restify/resource_spec.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjkxZWY3N2Y4NjE5ZmU1ZTE2ZjhjN2E5YjY3MGNiNjQzZGRlZjM1OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzJkNTNhNzM2MzE1ZTk1Y2IxMjc1NWUyMGViZjA5NjY2ZTAwMTkzNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzZhM2U3MGM5OWZiYjVkNTBiOWQxNDg5NWZjOGZhZjhiMGQwM2I4NWUyMjI0
|
10
|
+
NzkyNTE2ZjRmZThjMzg3ZDhjOTBjZWFhZDE2ODQ3OWVkZmFlN2JlNmVjZDUw
|
11
|
+
YmNmOTY2ZmYyNWM4MGNhODM5MzY5YmY5NGZmMjlkODIzZWJmY2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGRkN2Y5NDE0MGQ0NDE4OGI4NWUzZDAzYWFkYWRmMTZmZWVlYTU2Mzk3NGIy
|
14
|
+
ZTY3ZTcxOGMyMjNiYTdiOTE1MmZiZDU5MzZhZDNhYzU4ZDNiOTZiNjUzNTIw
|
15
|
+
YzNkZDZhNmMzMjEzZDFjNjY2ODdlYjdhMmM0MDM1Mjg3N2ZlMWI=
|
data/lib/restify/relations.rb
CHANGED
@@ -8,7 +8,7 @@ module Restify
|
|
8
8
|
# @return [Boolean] True if resource has relation, false otherwise.
|
9
9
|
#
|
10
10
|
def rel?(name)
|
11
|
-
relations.key? name
|
11
|
+
relations.key? name
|
12
12
|
end
|
13
13
|
alias_method :relation?, :rel?
|
14
14
|
alias_method :has_rel?, :rel?
|
@@ -20,7 +20,7 @@ module Restify
|
|
20
20
|
# @return [Relation] Relation.
|
21
21
|
#
|
22
22
|
def rel(name)
|
23
|
-
relations.fetch name
|
23
|
+
relations.fetch name
|
24
24
|
end
|
25
25
|
alias_method :relation, :rel
|
26
26
|
|
@@ -29,7 +29,7 @@ module Restify
|
|
29
29
|
# @return [Hash<String, Relation>] Relations.
|
30
30
|
#
|
31
31
|
def relations
|
32
|
-
@relations ||=
|
32
|
+
@relations ||= Hashie::Mash.new
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/restify/resource.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
module Restify
|
2
2
|
#
|
3
|
-
class Resource < Hashie::
|
3
|
+
class Resource < Hashie::Hash
|
4
4
|
include Result
|
5
5
|
include Relations
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# @return [MediaType] Resource media type.
|
10
|
-
#
|
11
|
-
attr_reader :media_type
|
6
|
+
include Hashie::Extensions::IndifferentAccess
|
7
|
+
include Hashie::Extensions::MethodReader
|
12
8
|
|
13
9
|
#
|
14
10
|
def initialize(client, data = {}, response = nil)
|
@@ -40,9 +36,9 @@ module Restify
|
|
40
36
|
def ==(other)
|
41
37
|
case other
|
42
38
|
when Resource
|
43
|
-
|
39
|
+
super && relations == other.relations
|
44
40
|
when Hash
|
45
|
-
|
41
|
+
super Hash[other.map{|k,v| [convert_key(k), v] }]
|
46
42
|
else
|
47
43
|
super
|
48
44
|
end
|
@@ -116,6 +116,32 @@ describe Restify::Resource do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
describe '#==' do
|
120
|
+
let(:data) { {a: 0, b: 1} }
|
121
|
+
|
122
|
+
it 'should eq hash' do
|
123
|
+
expect(res).to eq a: 0, b: 1
|
124
|
+
expect(res).to eq 'a' => 0, 'b' => 1
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#include?' do
|
129
|
+
let(:data) { {a: 0, b: 1} }
|
130
|
+
|
131
|
+
it 'should include partial hash' do
|
132
|
+
expect(res).to include a: 0
|
133
|
+
expect(res).to include b: 1
|
134
|
+
|
135
|
+
expect(res).to include 'a' => 0
|
136
|
+
expect(res).to include 'b' => 1
|
137
|
+
|
138
|
+
expect(res).to_not include a: 1
|
139
|
+
expect(res).to_not include c: 0
|
140
|
+
expect(res).to_not include 'a' => 1
|
141
|
+
expect(res).to_not include 'c' => 0
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
119
145
|
describe '#[]=' do
|
120
146
|
let(:data) { {a: 0, b: 1} }
|
121
147
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.2.1.
|
4
|
+
version: 0.1.2.1.b32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: obligation
|