Class: Seasar::Aop::Pointcut

Inherits:
Object
  • Object
show all
Defined in:
lib/seasar/aop/pointcut.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(point) ⇒ Pointcut

  • args

    1. Regexp|Symbol|String point



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/seasar/aop/pointcut.rb', line 28

def initialize(point)
  @point = point
  if @point.is_a?(Regexp)
    @matcher = lambda {|method_name| @point.match(method_name.to_s)}
  elsif @point.is_a?(Symbol)
    @matcher = lambda {|method_name| @point.to_s == method_name.to_s}
  elsif @point.is_a?(String)
    @matcher = lambda {|method_name| @point == method_name.to_s}
  else
    raise ArgumentError.new("unsupported point class #{@point}")
  end
end

Instance Attribute Details

#pointObject

Returns the value of attribute point.



40
41
42
# File 'lib/seasar/aop/pointcut.rb', line 40

def point
  @point
end

Instance Method Details

#applicable?(method_name) ⇒ Boolean

  • args

    1. String method_name

  • return

    • Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/seasar/aop/pointcut.rb', line 48

def applicable?(method_name)
  return @matcher.call(method_name)
end