Module: Compo::Branches::Branch

Includes:
Mixins::Movable, Mixins::ParentTracker, Mixins::UrlReferenceable
Included in:
Array, Hash, Leaf
Defined in:
lib/compo/branches/branch.rb

Overview

A movable, URL referenceable parent tracker

A Branch represents a fully-featured part of a composite object. This abstract pattern is implemented concretely by Leaf (a Branch with no children), Array (a Branch with a list of numerically identified children), and Hash (a Branch with a hash of key-identified children).

Instance Attribute Summary

Attributes included from Mixins::ParentTracker

#parent

Instance Method Summary collapse

Methods included from Mixins::UrlReferenceable

#child_url, #parent, #url

Methods included from Mixins::ParentTracker

#initialize, #update_parent

Methods included from Mixins::Movable

#move_to

Instance Method Details

#find_url(*args) {|The| ... } ⇒ Object

Traverses this Branch and its children following a URL

See Compo::Finders::Url for more information about what this means. This is a convenience wrapper over that method object, and is equivalent to ‘Compo::Finders::Url.find(self, *args, &block)’.

Examples:

From this Branch, find the item at ‘a/b/1’.

branch.on_url('a/b/1') { |item| p item }

Yield Parameters:

  • The (Object)

    found resource.

Returns:

  • (Object)

    Whatever is returned by the block.



30
31
32
# File 'lib/compo/branches/branch.rb', line 30

def find_url(*args, &block)
  Compo::Finders::Url.find(self, *args, &block)
end