Object
Traits never change an interface!!!!!!!!!!
Use traits
# File lib/matriarch/traits.rb, line 81 def include_traits(klass) klass.traits.each do |name, chain| traits[name].concat(chain) end end
prepend traits
# File lib/matriarch/traits.rb, line 88 def prepend_triats(klass) klass.traits.each do |name, chain| traits[name].replace(chain + traits[name]) end end
Define a pre-positioned trait/method.
# File lib/matriarch/traits.rb, line 61 def prior_to(name, returns=nil, &action) name = name.to_sym chain = traits[name] if chain.empty? define_method(name) do |*a| #&b| trait.input = a # oringal input chain.each do |tm| triat.output = tm.call(self, *a) #, &b) trait.trait = tm break if tm.return? end return trait.output end end chain.unshit(TraitMethod.new(self, returns, &action)) end
Remove a traits
# File lib/matriarch/traits.rb, line 95 def remove_traits(klass) traits.each do |name, chain| chain.delete_if do |tm| tm.container == klass end end end
Define a post-positioned trait/method.
# File lib/matriarch/traits.rb, line 40 def to(name, returns=nil, &action) name = name.to_sym chain = traits[name] if chain.empty? define_method(name) do |*a| #&b| trait.input = a # oringal input chain.each do |tm| trait.output = tm.call(self, *a) #, &b) trait.method = tm break if tm.return? end return trait.output end end chain << TraitMethod.new(self, returns, &action) end
Disabled; run with --debug to generate this.