Class: Joinpoint

Inherits:
Object show all
Defined in:
lib/cuts/aop.rb

Overview

TODO: pass actual method instead of using instace_method ?

Instance Method Summary collapse

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

#superObject



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