Sha256: 0473d78e197c3d91710544a64aa915c35f31182b7cd9d2978d677b323e64876d

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'compo/mixins'
require 'compo/finders'

module Compo
  module Branches
    # 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).
    module Branch
      include Mixins::Movable
      include Mixins::ParentTracker
      include Mixins::UrlReferenceable

      # 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)'.
      #
      # @api  public
      # @example  From this Branch, find the item at 'a/b/1'.
      #   branch.on_url('a/b/1') { |item| p item }
      #
      # @yieldparam [Object]  The found resource.
      #
      # @return [Object]  Whatever is returned by the block.
      def find_url(*args, &block)
        Compo::Finders::Url.find(self, *args, &block)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
compo-0.5.1 lib/compo/branches/branch.rb
compo-0.5.0 lib/compo/branches/branch.rb
compo-0.4.0 lib/compo/branches/branch.rb