module Lab42::AOP::After
Public Instance Methods
with_block(rcv, tgts, **kwds, &blk)
click to toggle source
# File lib/lab42/aop/after.rb, line 4 def with_block rcv, tgts, **kwds, &blk concerns = CrossConcern.get_methods rcv, Array( tgts ), **kwds concerns.each do | tgt_concern | _define_block_after tgt_concern, blk end end
with_methods(rcv, tgts, aops, **kwds)
click to toggle source
# File lib/lab42/aop/after.rb, line 11 def with_methods rcv, tgts, aops, **kwds Array( aops ).each do | aop | concerns = CrossConcern.get_methods rcv, Array( tgts ), **kwds concerns.each do | tgt_concern | _define_method_after tgt_concern, aop end end end
Private Instance Methods
_define_block_after(tgt_concern, blk)
click to toggle source
# File lib/lab42/aop/after.rb, line 21 def _define_block_after tgt_concern, blk unique_name = "__#{tgt_concern.name}_#{SecureRandom.uuid.gsub('-','_')}" tgt_concern.cls.send :define_method, unique_name, &blk tgt_concern.cls.send :define_method, tgt_concern.name do |*a, &b| tgt_concern.mthd.bind( self ).( *a, &b ).tap do send unique_name, *a, &b end end end
_define_method_after(tgt_concern, aop)
click to toggle source
# File lib/lab42/aop/after.rb, line 32 def _define_method_after tgt_concern, aop tgt_concern.cls.send :define_method, tgt_concern.name do |*a, &b| tgt_concern.mthd.bind( self ).( *a, &b ).tap do send( aop, *a, &b ) end end end