key_struct 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -119,6 +119,7 @@ Requires ruby >= 1.9.2. (Has been tested on MRI 1.9.2 and MRI 1.9.3)
119
119
 
120
120
  Release Notes:
121
121
 
122
+ * 0.2.1 - Bug fix: return false for == with an incompatible object. Was raising NoMethodError
122
123
  * 0.2.0 - Introduced <=> and to_hash
123
124
  * 0.1.0 - Introduced ==
124
125
  * 0.0.1 - Initial version
@@ -28,7 +28,7 @@ module KeyStruct
28
28
  raise ArgumentError, "Invalid argument(s): #{args.keys.map(&:inspect).join(' ')}; KeyStruct accepts #{keys.map(&:inspect).join(' ')}" if args.any?
29
29
  end
30
30
  define_method(:==) do |other|
31
- keys.all?{|key| self.send(key) == other.send(key)}
31
+ keys.all?{|key| other.respond_to?(key) and self.send(key) == other.send(key)}
32
32
  end
33
33
  define_method(:<=>) do |other|
34
34
  keys.each do |key|
@@ -1,3 +1,3 @@
1
1
  module KeyStruct
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -123,6 +123,10 @@ describe "KeyStruct" do
123
123
  @klass.new(:a => 1, :b => 2).should_not == @klass.new(:a => 1, :b => 3)
124
124
  end
125
125
 
126
+ it "returns false for == against incompatible object" do
127
+ @klass.new(:a => 1, :b => 2).should_not == 3
128
+ end
129
+
126
130
  it "compares based on primary key" do
127
131
  @klass.new(:a => 1, :b => 2).should < @klass.new(:a => 2, :b => 2)
128
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-04 00:00:00.000000000 Z
12
+ date: 2011-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70350516522720 !ruby/object:Gem::Requirement
16
+ requirement: &70104882335960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70350516522720
24
+ version_requirements: *70104882335960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov
27
- requirement: &70350516521800 !ruby/object:Gem::Requirement
27
+ requirement: &70104882335360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70350516521800
35
+ version_requirements: *70104882335360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: simplecov-gem-adapter
38
- requirement: &70350516536920 !ruby/object:Gem::Requirement
38
+ requirement: &70104882334760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70350516536920
46
+ version_requirements: *70104882334760
47
47
  description: Defines KeyStruct analogous to Struct, but constructor takes keyword
48
48
  arguments
49
49
  email:
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 1.8.10
88
+ rubygems_version: 1.8.12
89
89
  signing_key:
90
90
  specification_version: 3
91
91
  summary: Defines KeyStruct analogous to Struct, but constructor takes keyword arguments