Module: Tree::Pool
- 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
TODO: Make a separate gem. Then extend with with a lookup method and optionally an specialized #dot method
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(other) ⇒ Object
include PathAlgorithms.
Instance Method Summary collapse
Class Method Details
.included(other) ⇒ Object
include PathAlgorithms
13 14 15 16 17 |
# File 'lib/modular_tree/pool.rb', line 13 def self.included(other) other.extend(ClassMethods) other.instance_variable_set(:@pool, {}) super end |
Instance Method Details
#initialize(*args) ⇒ Object
19 20 21 22 23 |
# File 'lib/modular_tree/pool.rb', line 19 def initialize(*args) super !self.class.uid?(self.uid) or raise TreeError, "Duplicate UID: #{self.uid.inspect}" self.class.send(:[]=, self.uid, self) end |