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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/dish/plate.rb +11 -0
- data/lib/dish/version.rb +1 -1
- data/test/dish_test.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dae3424e63484c7eefa029c6275ea7792f6cc934
|
4
|
+
data.tar.gz: bcdc13166a4b3d0405a6aff08f1659fac73e2d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e806eebd00acb8515768d328a782407749573398bf50a61fd2c3083d366dff28bbace907de2b19c4488a2708d80f5f68803a2b471816fb7e4a5e2aa7b315f4fe
|
7
|
+
data.tar.gz: 7c6dec31c25149869bb990ec2288ada12f81c09144de40e8663dcd51f06fcbeb684e93c960d63ec01b81e0932a8aa120e66bf13f0a9b0e336c81ef7156da0a34
|
data/CHANGELOG.md
CHANGED
@@ -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'`.
|
data/lib/dish/plate.rb
CHANGED
@@ -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]
|
data/lib/dish/version.rb
CHANGED
data/test/dish_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|