dish 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: cc7f03afd4235d643f705eb69e4090e957e976a4
4
- data.tar.gz: 515e6465bb10f1abf86469cd3fdc0774c659c9b0
3
+ metadata.gz: dae3424e63484c7eefa029c6275ea7792f6cc934
4
+ data.tar.gz: bcdc13166a4b3d0405a6aff08f1659fac73e2d75
5
5
  SHA512:
6
- metadata.gz: b1a8a91507d2d016656d74065e3fafb57843e8abbab074830384f7443b36dd4400c3f0c52060995006c2d65514731063440e500e574ef0c3393554688f29fed2
7
- data.tar.gz: c575c4f366a7d8f7c2f5e19f1659b0189447f66560d3bd2b707c1406c6418d05a12acf93db7fdb5fdcb267be5bfce4a0d2625fadaf9fe8949903aa7711d28ae0
6
+ metadata.gz: e806eebd00acb8515768d328a782407749573398bf50a61fd2c3083d366dff28bbace907de2b19c4488a2708d80f5f68803a2b471816fb7e4a5e2aa7b315f4fe
7
+ data.tar.gz: 7c6dec31c25149869bb990ec2288ada12f81c09144de40e8663dcd51f06fcbeb684e93c960d63ec01b81e0932a8aa120e66bf13f0a9b0e336c81ef7156da0a34
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.6
4
+
5
+ * `Dish::Plate#==` now compares with the original hash, or anything that responds to `to_h`.
6
+ * `Dish::Plate#hash` is taken from the original hash. This enables using `group_by` and `uniq`.
7
+
3
8
  ## 0.0.5
4
9
 
5
10
  * Supports setting values via `some_dish_object.key = 'value'`.
@@ -15,6 +15,17 @@ module Dish
15
15
  @_value_cache = {}
16
16
  end
17
17
 
18
+ def hash
19
+ to_h.hash
20
+ end
21
+
22
+ def ==(other)
23
+ return false unless other.respond_to?(:to_h)
24
+ to_h == other.to_h
25
+ end
26
+
27
+ alias :eql? :==
28
+
18
29
  def method_missing(method, *args, &block)
19
30
  method = method.to_s
20
31
  key = method[0..-2]
@@ -1,3 +1,3 @@
1
1
  module Dish
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -145,4 +145,27 @@ class DishTest < Test::Unit::TestCase
145
145
 
146
146
  assert_equal [:a, :b], dish.methods[0..1]
147
147
  end
148
+
149
+ def test_hash_attribute
150
+ hash = { a: 1, b: 2 }
151
+ dish1 = Dish(hash)
152
+ dish2 = Dish(hash.dup)
153
+ assert_equal dish2.hash, dish1.hash
154
+ end
155
+
156
+ def test_equality
157
+ hash = { a: 1, b: 2 }
158
+ dish1 = Dish(hash)
159
+ dish2 = Dish(hash.dup)
160
+ assert dish1 == dish2
161
+ assert !(dish1 == 3)
162
+ end
163
+
164
+ def test_eql
165
+ hash = { a: 1, b: 2 }
166
+ dish1 = Dish(hash)
167
+ dish2 = Dish(hash.dup)
168
+ assert dish1.eql?(dish2)
169
+ assert !dish1.eql?(3)
170
+ end
148
171
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dish
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
  - Lasse Bunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler