is_a_collection 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/is_a_collection.rb +2 -2
- data/spec/is_a_collection_spec.rb +1 -1
- metadata +3 -3
data/lib/is_a_collection.rb
CHANGED
@@ -17,7 +17,7 @@ class Class
|
|
17
17
|
|
18
18
|
define_method :add_to_collection do
|
19
19
|
primary_key = __send__(id_method)
|
20
|
-
raise IsACollection::
|
20
|
+
raise IsACollection::DuplicateKeyError if self.class.__collection[primary_key]
|
21
21
|
self.class.__collection[primary_key] = self
|
22
22
|
|
23
23
|
indices.each do |index|
|
@@ -43,7 +43,7 @@ class Class
|
|
43
43
|
end
|
44
44
|
|
45
45
|
module IsACollection
|
46
|
-
class
|
46
|
+
class DuplicateKeyError < StandardError; end
|
47
47
|
|
48
48
|
module InstanceMethods
|
49
49
|
def initialize(*args, &block)
|
@@ -59,7 +59,7 @@ describe "is_a_collection" do
|
|
59
59
|
describe "on primary key collision" do
|
60
60
|
it "raise an error" do
|
61
61
|
b1 = B.new('a key')
|
62
|
-
lambda{ B.new('a key') }.should raise_error(IsACollection::
|
62
|
+
lambda{ B.new('a key') }.should raise_error(IsACollection::DuplicateKeyError)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
describe "#find" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: is_a_collection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Niko Dittmann
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-30 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements: []
|
58
58
|
|
59
59
|
rubyforge_project: nowarning
|
60
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.8.11
|
61
61
|
signing_key:
|
62
62
|
specification_version: 3
|
63
63
|
summary: "A small gem that adds #find, #all and #destroy to a class to keep track of its instances."
|