compo 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 914e22d4c5fb780ddfb95a6b71ecabf0046200b1
4
- data.tar.gz: 91fa7096c61860f8aa06b7d773a3c8a490ac1cb6
3
+ metadata.gz: 27f469c00cf86d294398a92e891752c829380282
4
+ data.tar.gz: f3e4f7776ea089dcd80d77a0827f4c77cca6c728
5
5
  SHA512:
6
- metadata.gz: b6477ff141c788b2889b06c7674bb0ffcb157880f739e7ab0532a866e917fe4df56c19dffb8794b69caaffb1f011ff463326435460334a95c58813cdea3d2c4c
7
- data.tar.gz: 42527748f975f4e21bfbf8ca7b3b8cc46cda5304eaf586bd5ea37961c0ff9d998cec64641c8f3e82611248626796fdb1b7a352afb95e2037b459b04e7599e263
6
+ metadata.gz: c0f0d6d791a42006eeb243311980e21c04338b68ccb4157c54303db2f77b6d08d962a6bdc709385188b52be2fed5b20125c003515294d5e9f1d06fd06f6bca67
7
+ data.tar.gz: 35962706d2103ccad4c75fa5c4ed6131daa0bc2a9eef3361a056b7edaa692620e6975bb03999744d539fbff272c72ac5a87307ab0e24f9509e4fc7bb4296d5e5
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.2 (2013-12-27)
2
+ - Implement and specify #get_child.
3
+
1
4
  0.1.1 (2013-12-27)
2
5
  - Avoid a function name clash between #remove_parent on a child and
3
6
  #remove_parent on a parent. The latter is now #remove_parent_of.
@@ -69,6 +69,23 @@ module Compo
69
69
  remove_id!(id).tap(&method(:remove_parent_of))
70
70
  end
71
71
 
72
+ # Gets the child in this Composite with the given ID
73
+ #
74
+ # @api public
75
+ # @example Gets the child with ID :in, if children is {in: 3}.
76
+ # composite.get_child(:in)
77
+ # #=> 3
78
+ # @example Fails to get the child with ID :out, if children is {in: 3}.
79
+ # composite.get_child(:out)
80
+ # #=> nil
81
+ #
82
+ # @param id [Object] The ID of the child to get from this Composite.
83
+ #
84
+ # @return [Object] The child if successful; nil otherwise.
85
+ def get_child(id)
86
+ children[id]
87
+ end
88
+
72
89
  def_delegator :children, :each
73
90
 
74
91
  protected
data/lib/compo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # The current gem version. See CHANGELOG for information.
2
2
  module Compo
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
@@ -246,4 +246,24 @@ describe MockComposite do
246
246
  subject.each
247
247
  end
248
248
  end
249
+
250
+ describe '#get_child' do
251
+ before(:each) { allow(subject).to receive(:children).and_return(children) }
252
+ let(:children) { { in_children: child } }
253
+
254
+ it 'calls #children' do
255
+ expect(subject).to receive(:children).once
256
+ subject.get_child(:in_children)
257
+ end
258
+
259
+ context 'when the argument is in #children' do
260
+ it 'returns the child' do
261
+ expect(subject.get_child(:in_children)).to eq(child)
262
+ end
263
+ end
264
+
265
+ context 'when the argument is in #children' do
266
+ specify { expect(subject.get_child(:not_in_children)).to be_nil }
267
+ end
268
+ end
249
269
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Windsor