collection_of 1.0.4 → 1.0.5
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.
- checksums.yaml +8 -8
- data/lib/collection_of/collection.rb +4 -0
- data/lib/collection_of/version.rb +1 -1
- data/spec/collection_spec.rb +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTI4NDIzNzJiYjE1MThhZDY5MjhlNjVkZDM1NDBhMDc1ZTg1Yjg4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTAxZjZiMjg4NzkxZTI3ZTgxNmFiMGI0ODhhNTlmNTJlZWEwMWQ2Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTMzYWU5NjdkNGQ2NmFjYjMyNTQ4MmQ3YjRmYzFkMjVlZTFlZGZiMzY1YTRl
|
10
|
+
ZTBkOTBjNmZhNGQxZTVhOTljZGZiZWYxMmIwZGE4ZWFkMmIwY2JhZjQzNDRh
|
11
|
+
ODE5N2VhZThlMzQzNDYxYjI1ODliNzViMDliMTdkNDE1ODExYTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzNjMDE3YjY3ZjdhM2M0Y2E5NzA3NzRhNThkMWFiMWRjMDdmMDVkNTA2YjA3
|
14
|
+
OGQ4NTYwNDEwZmY0MGE5YzAxOTYxYmU0MDFmMTRmZTAyZjZlMjUzOWUzZGNj
|
15
|
+
OTk1ZjhmODI0Y2MwNDM5MzI4ZWMxNzIyZGEwODQ2NjY3YTIxZmI=
|
@@ -76,6 +76,10 @@ class Collection
|
|
76
76
|
self.class.new(klass, select{ |i| items.include?(i.name.to_sym) })
|
77
77
|
end
|
78
78
|
|
79
|
+
def delete(*items)
|
80
|
+
@collection = reject{ |i| items.include?(i.name) }
|
81
|
+
end
|
82
|
+
|
79
83
|
def ==(other)
|
80
84
|
return other == @collection if other.is_a?(self.class)
|
81
85
|
return @collection == other if other.is_a?(Array)
|
data/spec/collection_spec.rb
CHANGED
@@ -244,4 +244,29 @@ describe Collection do
|
|
244
244
|
it { should_not == described_class[Widget, [w2]] }
|
245
245
|
it { should_not == described_class[Widget] }
|
246
246
|
end
|
247
|
+
|
248
|
+
describe "#delete" do
|
249
|
+
let(:c) { described_class[Widget] }
|
250
|
+
let(:w1) { Widget.new(:one) }
|
251
|
+
let(:w2) { Widget.new(:two) }
|
252
|
+
|
253
|
+
subject { c }
|
254
|
+
|
255
|
+
before { c << w1 << w2 }
|
256
|
+
|
257
|
+
context "when an included item is specified" do
|
258
|
+
before { c.delete(:one) }
|
259
|
+
it { should == [w2] }
|
260
|
+
end
|
261
|
+
|
262
|
+
context "when all included items are specified" do
|
263
|
+
before { c.delete(:one, :two) }
|
264
|
+
it { should be_empty }
|
265
|
+
end
|
266
|
+
|
267
|
+
context "when no included items are specified" do
|
268
|
+
before { c.delete(:three) }
|
269
|
+
it { should == [w1, w2] }
|
270
|
+
end
|
271
|
+
end
|
247
272
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collection_of
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Vandersluis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
type: :runtime
|