Class: Joinpoint
Overview
TODO: pass actual method instead of using instace_method ?
Instance Method Summary collapse
- #==(sym) ⇒ Object
- #===(match) ⇒ Object
-
#initialize(object, base, method, *args, &block) ⇒ Joinpoint
constructor
A new instance of Joinpoint.
- #super ⇒ Object
Constructor Details
#initialize(object, base, method, *args, &block) ⇒ Joinpoint
Returns a new instance of Joinpoint.
31 32 33 34 35 36 37 |
# File 'lib/cuts/aop.rb', line 31 def initialize(object, base, method, *args, &block) @object = object @base = base @method = method @args = args @block = block end |
Instance Method Details
#==(sym) ⇒ Object
48 49 50 |
# File 'lib/cuts/aop.rb', line 48 def ==(sym) sym.to_sym == @method.to_sym end |
#===(match) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/cuts/aop.rb', line 39 def ===(match) case match when Proc match.call(self) else # Pattern matches (not supported presently) match.to_sym == @method.to_sym end end |
#super ⇒ Object
54 55 56 57 |
# File 'lib/cuts/aop.rb', line 54 def super anc = @object.class.ancestors.find{ |anc| anc.method_defined?(@method) } anc.instance_method(@method).bind(@object).call(*@args, &@block) end |