Sha256: ad8d57dfecbbec973888d3bb74f1c1c02ad2d0dd3c83cd95280baf43fea4c426

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

module Dogviz
  module Parent
    def find_all(&matcher)
      raise MissingMatchBlockError.new unless block_given?
      @by_name.find_all(&matcher)
    end

    def find(name=nil, &matcher)
      if block_given?
        @by_name.find(&matcher)
      else
        raise 'Need to provide name or block' if name.nil?
        @by_name.lookup name
      end
    end

    def thing(name, options={})
      add Thing.new self, name, options
    end

    def container(name, options={})
      add Container.new self, name, options
    end

    def logical_container(name, options={})
      add LogicalContainer.new self, name, options
    end

    def group(name, options={})
      logical_container name, options
    end

    def add(child)
      @children << child
      nominate child.name => child if auto_nominate?
      child
    end

    def root?
      not respond_to?(:parent)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dogviz-0.0.22 lib/dogviz/parent.rb