collection_of 1.0.2 → 1.0.3

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
- MjM0ZDM1ZDIyZWFhZmNiNjJkOTNmYjAwMjlhOGQwNGYzOTdkZmY5Yw==
4
+ YTUzMGY4NTExZjJkOGU1NGUwZmFhNTU5NGY3NTA0YjZjZDQxOTNkYQ==
5
5
  data.tar.gz: !binary |-
6
- ZWIwZmU4YjQ5NjMyYWY1YWExMTQ3ZTExMzAxYmU0YzEzYzg2OWQ2OA==
6
+ N2UzZjFhMTA5M2ZiYTFhOTUwMWI4ZjA5ODRkN2E2NTAxOTI5Zjc5MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWE5NDc3MTlmZjcwZTA4NDFmYzlkNjUwN2YyNzU0MDgxYWU1MjhmZmYyODFj
10
- ZTU0N2RlZjc2Y2RlYTg3NDJmNWVlYzkxZTRlMWNjODdmYmUzZmJjYmVmODA2
11
- N2I0MjA0MmVlNzZlMmI1YWE3OGUwYTYyM2MyNDA2NzlkY2RlYTQ=
9
+ ZjRlZGY4MTllODBiZDgyY2I5ODhiNDcxMjI1ZDFjZDE5MTAyZTJlNWQ5NGQx
10
+ MjcyNzAwNmU2NzU3NjNjMjYxMzg2NmQyNTNhMThmNmM4MmZhYzRkZWYyZjlm
11
+ ZDE0Yjc1MDcxZTcyNjdkZTA3MDQzZjgwZDY4MjZlZDJiNTA4MmI=
12
12
  data.tar.gz: !binary |-
13
- MmE3NDg4N2U2NmU2Y2E4ZDU1YzA1YzhmNDExMjU4Mzk5YTQ0OTE3YTgzMGE0
14
- MTdmOGE0MDQ3YTEwNjhjMjlhZDVlY2Q1OWE2NTNlNDUxNmJiZTdlYjhiYzAx
15
- N2U1MTE3OWEyM2EzMDRmMWY0NjdlY2RiYmE1M2U0YjJjOTk5NDM=
13
+ MTQ1NDRkMWIyZWVhNmQ1YTZkNjQyMTU3NDM5NDI4MDc5YTMwNWU2NzU1ZDUw
14
+ MjIzNWNlZDllNTU2NjNhNGE5NTgxNTBjMjM2YzM2NjY5NmFlOGNkNmEwZjI3
15
+ MDM4MGExOGQwZWE3Yzg3NTk2MzAwMjI1MGM0MDY0YTAxOTdhZGI=
data/lib/collection_of.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'collection_of/collection'
2
1
  require 'collection_of/version'
2
+ require 'collection_of/collection'
3
3
 
4
4
  module CollectionOf
5
5
  def self.[](klass, *args)
@@ -55,6 +55,11 @@ class Collection
55
55
  @collection.map{ |i| i.name.to_sym }
56
56
  end
57
57
 
58
+ def key?(key)
59
+ keys.include?(key.to_sym)
60
+ end
61
+ alias_method :has_key?, :key?
62
+
58
63
  def include?(item)
59
64
  return true if @collection.include?(item)
60
65
  return keys.include?(item.to_sym) if item.respond_to?(:to_sym)
@@ -1,3 +1,3 @@
1
1
  module CollectionOf
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -153,6 +153,16 @@ describe Collection do
153
153
  its(:keys) { should == [:one, :two] }
154
154
  end
155
155
 
156
+ describe "#key?" do
157
+ let(:w1) { Widget.new(:one) }
158
+ subject { described_class[Widget] }
159
+
160
+ before { subject << w1 }
161
+
162
+ it { should have_key(:one) }
163
+ it { should_not have_key(:two) }
164
+ end
165
+
156
166
  describe "#include?" do
157
167
  let(:w1) { Widget.new(:one) }
158
168
  let(:w2) { Widget.new(:one) }
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.2
4
+ version: 1.0.3
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-10-19 00:00:00.000000000 Z
11
+ date: 2013-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  type: :runtime