lib/compo/composite.rb in compo-0.1.1 vs lib/compo/composite.rb in compo-0.1.2

- old
+ new

@@ -67,9 +67,26 @@ # @return [Object] The removed child if successful; nil otherwise. def remove_id(id) remove_id!(id).tap(&method(:remove_parent_of)) end + # Gets the child in this Composite with the given ID + # + # @api public + # @example Gets the child with ID :in, if children is {in: 3}. + # composite.get_child(:in) + # #=> 3 + # @example Fails to get the child with ID :out, if children is {in: 3}. + # composite.get_child(:out) + # #=> nil + # + # @param id [Object] The ID of the child to get from this Composite. + # + # @return [Object] The child if successful; nil otherwise. + def get_child(id) + children[id] + end + def_delegator :children, :each protected # Assigns this object to a child as its parent