ruby_json_api_client 0.0.8 → 0.0.9

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: 27dd99623e61dabe0f07bf7b05c807be2d26e2c3
4
- data.tar.gz: 1b0c603178890d1b94f344a12b9d7f4644ef4268
3
+ metadata.gz: 72cd1d75431c099d28561aef966ee1d89a8f6364
4
+ data.tar.gz: 4ef13bbf617f22b09e3fdcfa3ccbdffa66aec743
5
5
  SHA512:
6
- metadata.gz: 34b83bfd9710ded5031ea737485e94771de4cf5d2f4179060824ca675cd3bdb89b07e3974b465001a949993e0156d6ab92d40c95b6502bc668211f81a01f33d2
7
- data.tar.gz: 17beb37bc8d83be99cbcfd1bf3e93b6e0875725f17be48d02f3f859e348660b8e39d1caab861d51431f2f97041bcd91a599e5a3e88428114f9d2aec729d12194
6
+ metadata.gz: f6d1457c4151ba98842f42ff8968238abe3b91161575c4b6c7df959c72ce9c26de9e54e4e43fe8166d842b0c46007e706dcd59c99bb336c9774eb113db7a9e42
7
+ data.tar.gz: 351f6cfd3131f5e542c8a980d49571bf22d843be432d6ab2908379bd53dbd7dfda04d045af16201bef1630d2042c1d4fe7df95fe19eb7b399b22d43c919d3f4b
@@ -172,6 +172,11 @@ module RubyJsonApiClient
172
172
 
173
173
  klass_match && ids_match
174
174
  end
175
+
176
+ def hash
177
+ self.send(self.class._identifier).hash
178
+ end
179
+
175
180
  alias_method :eql?, :==
176
181
  alias_method :equal?, :==
177
182
  end
@@ -1,3 +1,3 @@
1
1
  module RubyJsonApiClient
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -120,4 +120,32 @@ describe RubyJsonApiClient::Base do
120
120
  it { should eq(true) }
121
121
  end
122
122
  end
123
+
124
+ describe :hash do
125
+ context "two objects of different classes" do
126
+ subject { Person.new(id: 1).hash == Item.new(id: 1).hash }
127
+ it { should eq(true) }
128
+ end
129
+
130
+ context "two objects of the same class but different ids" do
131
+ subject { Person.new(id: 1).hash == Person.new(id: 2).hash }
132
+ it { should eq(false) }
133
+ end
134
+
135
+ context "two objects with the same klass and id" do
136
+ subject { Person.new(id: 1).hash == Person.new(id: 1).hash }
137
+ it { should eq(true) }
138
+ end
139
+
140
+ context "the same instance" do
141
+ let(:person) { Person.new(id: 1) }
142
+ subject { person.hash == person.hash }
143
+ it { should eq(true) }
144
+ end
145
+
146
+ context "two objects with non standard identifiers" do
147
+ subject { Thing.new(uuid: 'x').hash == Thing.new(uuid: 'x').hash }
148
+ it { should eq(true) }
149
+ end
150
+ end
123
151
  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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Toronto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-14 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -313,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
313
  version: '0'
314
314
  requirements: []
315
315
  rubyforge_project:
316
- rubygems_version: 2.2.3
316
+ rubygems_version: 2.4.8
317
317
  signing_key:
318
318
  specification_version: 4
319
319
  summary: API client for activemodel instances