Methods
Public Instance methods
Alias for post
Alias for wrap
Alias for pre
Alias for wrap
Add a post (after) advice.
This method is also aliased as
after
[ show source ]
# File lib/facets/more/aspects.rb, line 211 def post(*args, &block) o = options = { :join => :post, :where => :append, } options.update(args.pop) if args.last.is_a?(Hash) if block_given? new_advices = [ Advice.new(block, options) ] else new_advices = args.collect { |a| Advice.new(a, options) } end # if options[:where] == :prepend # self.advices = advices + self.advices # else # self.advices = self.advices + advices # end self.advices!.concat(new_advices) end
Add a pre (before) advice.
This method is also aliased as
before
[ show source ]
# File lib/facets/more/aspects.rb, line 188 def pre(*args, &block) o = options = { :join => :pre, :where => :prepend, } options.update(args.pop) if args.last.is_a?(Hash) if block_given? new_advices = [ Advice.new(block, options) ] else new_advices = args.collect { |a| Advice.new(a, options) } end # if options[:where] == :prepend # self.advices = advices + self.advices # else # self.advices = self.advices + advices # end self.advices!.concat(new_advices) end
Add a wrap (arround) aspect. An aspect is a class that responds to the before and after advices.
[ show source ]
# File lib/facets/more/aspects.rb, line 235 def wrap(*args) o = options = { :pre => :pre, :post => :post } options.update(args.pop) if args.last.is_a?(Hash) for aspect in args self.advices! << Advice.new(aspect, options) end end