Sha256: 9899c7411ec179c0490921aeb95ff716e8cb02fdcad780e6ebd0775f0a39e977

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 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

2 entries across 2 versions & 1 rubygems

Version Path
dogviz-0.0.21 lib/dogviz/parent.rb
dogviz-0.0.20 lib/dogviz/parent.rb