class Aspector::Advice
A single aspect advice representation
Constants
- TYPES
All available advices types that we support
Attributes
advice_block[R]
advice_code[R]
index[RW]
method_matcher[R]
name[R]
options[R]
type[R]
Public Class Methods
new(parent, type, method_matcher, with_method, options = {}, &block)
click to toggle source
# File lib/aspector/advice.rb, line 29 def initialize(parent, type, method_matcher, with_method, options = {}, &block) @type = type @parent = parent @options = options @advice_block = block @method_matcher = method_matcher @name = @options[:name] || "advice_#{index}" if with_method.is_a? Symbol @with_method = with_method else @advice_code = with_method end end
Public Instance Methods
match?(method, context = nil)
click to toggle source
# File lib/aspector/advice.rb, line 50 def match?(method, context = nil) return false if method == with_method return false unless @method_matcher.match?(method, context) return true unless @options[:except] @except ||= MethodMatcher.new(@options[:except]) !@except.match?(method) end
to_s()
click to toggle source
# File lib/aspector/advice.rb, line 65 def to_s s = "#{name}: " s << type.to_s.upcase s << ' [' << @method_matcher.to_s << '] DO ' if @with_method s << @with_method.to_s else s << 'stuff in block' end s << ' WITH OPTIONS ' << @options.inspect s end
use_deferred_logic?(logic)
click to toggle source
# File lib/aspector/advice.rb, line 61 def use_deferred_logic?(logic) method_matcher.use_deferred_logic? logic end
with_method()
click to toggle source
# File lib/aspector/advice.rb, line 44 def with_method return nil if @advice_code @with_method ||= "aop_#{hash.abs}" end