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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjFmODExYzA1MWQyMWQyYjQ3NDM0M2I5NWQ3NDRmYTBkYjMzZGRhZA==
4
+ YjkxZWY3N2Y4NjE5ZmU1ZTE2ZjhjN2E5YjY3MGNiNjQzZGRlZjM1OA==
5
5
  data.tar.gz: !binary |-
6
- MWUxMzRiN2RlZmEwZGVmMTBmNzg0ZWMzODFiMjBlOGUwN2Y5YmNkOA==
6
+ YzJkNTNhNzM2MzE1ZTk1Y2IxMjc1NWUyMGViZjA5NjY2ZTAwMTkzNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmNiMmJkNTQ4Y2Y4MjBiYzllOTBkNjE1NWExZTE0NDhhNTk3ZmRjYjE0NTky
10
- N2VlYTkzZjI3NDI5N2I5MDE2M2FlYTNkYWJiYzM2Njc5OTY4YTFjOWJjZDdm
11
- YmNhMTg2ODU0ZTg1YWNjZWQ2MTI0OGU3ZWRkNTYwNjg0ZmFhODM=
9
+ NzZhM2U3MGM5OWZiYjVkNTBiOWQxNDg5NWZjOGZhZjhiMGQwM2I4NWUyMjI0
10
+ NzkyNTE2ZjRmZThjMzg3ZDhjOTBjZWFhZDE2ODQ3OWVkZmFlN2JlNmVjZDUw
11
+ YmNmOTY2ZmYyNWM4MGNhODM5MzY5YmY5NGZmMjlkODIzZWJmY2Q=
12
12
  data.tar.gz: !binary |-
13
- Yzc2ZjVhY2Q1NzYyOGIwNmRmYzMwOTMxZDYwOWJlNDYzMjExODc1MTViNjk3
14
- MDBiMGI2MWUxNzc1OGU4OWI1ZjJmMzBiMjI4NzdlNzhkMjZmZDYyZWZjZDY4
15
- MmUwYTcyM2Y0NzdhNGI5M2VhZTZjNDVlZTJjZjI3YmViZDA0ZDE=
13
+ NGRkN2Y5NDE0MGQ0NDE4OGI4NWUzZDAzYWFkYWRmMTZmZWVlYTU2Mzk3NGIy
14
+ ZTY3ZTcxOGMyMjNiYTdiOTE1MmZiZDU5MzZhZDNhYzU4ZDNiOTZiNjUzNTIw
15
+ YzNkZDZhNmMzMjEzZDFjNjY2ODdlYjdhMmM0MDM1Mjg3N2ZlMWI=
@@ -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.to_s
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.to_s
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 ||= Hash.new
32
+ @relations ||= Hashie::Mash.new
33
33
  end
34
34
  end
35
35
  end
@@ -1,14 +1,10 @@
1
1
  module Restify
2
2
  #
3
- class Resource < Hashie::Mash
3
+ class Resource < Hashie::Hash
4
4
  include Result
5
5
  include Relations
6
-
7
- # Return content Media-Type.
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
- @data == other.data && relations == other.relations
39
+ super && relations == other.relations
44
40
  when Hash
45
- @data == other
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.b28
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-09 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: obligation