lib/dogviz.rb in dogviz-0.0.11 vs lib/dogviz.rb in dogviz-0.0.12
- old
+ new
@@ -13,10 +13,25 @@
module Flowable
def does(action)
Process.new(self, action)
end
end
+ module Nominator
+ def nominate(names_to_nominees)
+ names_to_nominees.each {|name, nominee|
+ self.class.send(:define_method, name) do
+ nominee
+ end
+ }
+ end
+ def nominate_from(nominee_nominator, *nominee_names)
+ nominee_names.each {|name|
+ accessor_sym = name.to_s.to_sym
+ nominate accessor_sym => nominee_nominator.send(accessor_sym)
+ }
+ end
+ end
module Common
def create_id(name, parent)
parts = []
parts << parent.id if parent.respond_to? :id
parts += name.split /\s/
@@ -84,17 +99,10 @@
def on_top_rollup?
rollup? && !under_rollup?
end
end
module Parent
- def nominate(names_to_values)
- names_to_values.each {|name, value|
- self.class.send(:define_method, name) do
- value
- end
- }
- end
def find_all(&matcher)
raise MissingMatchBlockError.new unless block_given?
@by_name.find_all &matcher
end
def find(name=nil, &matcher)
@@ -123,10 +131,11 @@
end
end
class Thing
include Common
+ include Nominator
include Flowable
attr_reader :parent
attr_reader :name, :id, :pointers, :edge_heads
def initialize(parent, name, options = {})
@@ -236,9 +245,10 @@
end
end
class Container
include Common
+ include Nominator
include Parent
attr_reader :parent
attr_reader :name, :id, :node, :render_id, :render_type, :render_options, :children
def initialize(parent, name, options = {})