collection_of 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTgyMjEzYWU2ZmRkNzIwM2RiMTVlY2ExNzQyMzM1ZTI2MGJjNjQ4ZA==
4
+ MjM0ZDM1ZDIyZWFhZmNiNjJkOTNmYjAwMjlhOGQwNGYzOTdkZmY5Yw==
5
5
  data.tar.gz: !binary |-
6
- N2U1YzY1YjQ5Y2IzMGMwYzZiNTg5MTE2YzMwNTRjNTU3Mzk4MTI1Mg==
6
+ ZWIwZmU4YjQ5NjMyYWY1YWExMTQ3ZTExMzAxYmU0YzEzYzg2OWQ2OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDU3OTU2ODFmNTU5YjBiMjQzNzIwNjVkYTczN2Y2YjUxYWIzMDE4MWRiNDc1
10
- ZTY4Y2U0NGFiMWRjM2NhNjQyMjQ5ODlhNjFlOGZhM2M2MDczOTNhOWQ0NGQ0
11
- NWIzODEwY2RlYmE0ZDI4MjZkYzgzYTA0YzgyNzY5N2Y5OTg5YTc=
9
+ NWE5NDc3MTlmZjcwZTA4NDFmYzlkNjUwN2YyNzU0MDgxYWU1MjhmZmYyODFj
10
+ ZTU0N2RlZjc2Y2RlYTg3NDJmNWVlYzkxZTRlMWNjODdmYmUzZmJjYmVmODA2
11
+ N2I0MjA0MmVlNzZlMmI1YWE3OGUwYTYyM2MyNDA2NzlkY2RlYTQ=
12
12
  data.tar.gz: !binary |-
13
- MThkMGZmNGE5ZThhYTBlNzdhZjgzYTU4YmRkNzAwYTljMTBiMGM5NTBhYzgw
14
- MWM0MDhkOTI5YmQ3Nzc5NWViNDdmZjY4MmZlYTUzMzcwZGU2NmVkNmExYmE3
15
- Zjc2ODY2Yjk4MTYwOTFkYTBhMjY4ZDk3N2RlNWJlNDhiYTE3YmU=
13
+ MmE3NDg4N2U2NmU2Y2E4ZDU1YzA1YzhmNDExMjU4Mzk5YTQ0OTE3YTgzMGE0
14
+ MTdmOGE0MDQ3YTEwNjhjMjlhZDVlY2Q1OWE2NTNlNDUxNmJiZTdlYjhiYzAx
15
+ N2U1MTE3OWEyM2EzMDRmMWY0NjdlY2RiYmE1M2U0YjJjOTk5NDM=
@@ -51,6 +51,16 @@ class Collection
51
51
  @collection << obj
52
52
  end
53
53
 
54
+ def keys
55
+ @collection.map{ |i| i.name.to_sym }
56
+ end
57
+
58
+ def include?(item)
59
+ return true if @collection.include?(item)
60
+ return keys.include?(item.to_sym) if item.respond_to?(:to_sym)
61
+ return false
62
+ end
63
+
54
64
  def except(*items)
55
65
  items.map!(&:to_sym)
56
66
  self.class.new(klass, reject{ |i| items.include?(i.name.to_sym) })
@@ -1,3 +1,3 @@
1
1
  module CollectionOf
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -143,6 +143,28 @@ describe Collection do
143
143
  end
144
144
  end
145
145
 
146
+ describe "#keys" do
147
+ let(:w1) { Widget.new(:one) }
148
+ let(:w2) { Widget.new(:two) }
149
+ subject { described_class[Widget] }
150
+
151
+ before { subject << w1 << w2 }
152
+
153
+ its(:keys) { should == [:one, :two] }
154
+ end
155
+
156
+ describe "#include?" do
157
+ let(:w1) { Widget.new(:one) }
158
+ let(:w2) { Widget.new(:one) }
159
+ subject { described_class[Widget] }
160
+ before { subject << w1 }
161
+
162
+ it { should include w1 }
163
+ it { should include :one }
164
+ it { should_not include w2 }
165
+ it { should_not include :two }
166
+ end
167
+
146
168
  describe "#except" do
147
169
  let(:c) { described_class[Widget] }
148
170
  let(:w1) { Widget.new(:one) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collection_of
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vandersluis