Module: Tree::Pool
- Includes:
- PathAlgorithms
- Defined in:
- lib/modular_tree/pool.rb
Overview
A pool assumes objects has a unique identifier
Pool adds a @pool class variable to the including class and all of its subclasses
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Methods included from PathAlgorithms
#lookup, #path, #search, #separator, #separator=, #uid
Methods included from UpTreeAlgorithms
Methods included from BranchesProperty
#bare?, #branches, #each_branch
Methods included from NodeProperty
Methods included from KeyProperty
Class Method Details
.included(other) ⇒ Object
10 11 12 13 14 |
# File 'lib/modular_tree/pool.rb', line 10 def self.included(other) other.extend(ClassMethods) other.instance_variable_set(:@pool, {}) super end |
Instance Method Details
#initialize(*args) ⇒ Object
16 17 18 19 20 |
# File 'lib/modular_tree/pool.rb', line 16 def initialize(*args) super !self.class.uid?(self.uid) or raise TreeError, "Duplicate UID: #{self.uid}" self.class.send(:[]=, self.uid, self) end |