Class: Aspekt::Advice
Instance Method Summary collapse
-
#initialize(opts) ⇒ Advice
constructor
Example usage advice = Aspekt::Advice.new ( type: :before, pointcut: pointcut ) do |joinpoint| puts “before #joinpoint” end.
Methods inherited from Object
Constructor Details
#initialize(opts) ⇒ Advice
Example usage
advice = Aspekt::Advice.new ( type: :before, pointcut: pointcut ) do |joinpoint|
puts "before #{joinpoint}"
end
advice = Aspekt::Advice.new ( type: :around, pointcuts: [pointcut1, pointcut2]) do |joinpoint|
puts "around :start for #{joinpoint}"
return_value = joinpoint.proceed
puts "around :end for #{joinpoint}"
end
124 125 126 127 128 129 |
# File 'lib/aspekt.rb', line 124 def initialize opts opts[:pointcuts] = [opts.delete(:pointcut)].flatten if opts[:pointcut] super opts raise ArgumentError, "type has to be Symbol: before, after or around" unless [:before, :after, :around].include?(self[:type]) raise ArgumentError, "no pointcut defined" unless self[:pointcuts].length end |