See examples/recipe.rb and examples/recipe2.rb how this works at the moment.
Start deflecting method calls named id to the from class using the Deflector instance deflector. After that yield to the given block and stop deflecting again.
# File lib/dslkit/polite.rb, line 487 def deflect(from, id, deflector) @@sync.synchronize do begin deflect_start(from, id, deflector) yield ensure deflect_stop(from, id) end end end
Return true if method id is deflected from class from, otherwise return false.
# File lib/dslkit/polite.rb, line 480 def deflect?(from, id) Deflect.deflect?(from, id) end
Start deflecting method calls named id to the from class using the Deflector instance deflector.
# File lib/dslkit/polite.rb, line 454 def deflect_start(from, id, deflector) @@sync.synchronize do Deflect.deflecting ||= DeflectorCollection.new Deflect.deflecting.member?(from, id) and raise DeflectError, "#{from}##{id} is already deflected" Deflect.deflecting.add(from, id, deflector) from.class_eval do define_method(id) do |*args| if Deflect.deflecting and d = Deflect.deflecting.find(self.class, id) d.call(self, id, *args) else super(*args) end end end end end
Stop deflection method calls named id to class from.
# File lib/dslkit/polite.rb, line 499 def deflect_stop(from, id) @@sync.synchronize do Deflect.deflecting.delete(from, id) or raise DeflectError, "#{from}##{id} is not deflected from" from.instance_eval { remove_method id } end end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.