module Lab42::AOP::Around
Public Instance Methods
with_block(rcv, tgts, **kwds, &blk)
click to toggle source
# File lib/lab42/aop/around.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_around tgt_concern, blk end end
with_methods(rcv, tgts, aops, **kwds)
click to toggle source
# File lib/lab42/aop/around.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_around tgt_concern, aop end end end
Private Instance Methods
_define_block_around(tgt_concern, blk)
click to toggle source
# File lib/lab42/aop/around.rb, line 21 def _define_block_around 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| result_wrapper = Tools.mk_result_wrapper tgt_concern.mthd.bind( self ), tgt_concern.name send unique_name, result_wrapper, *a, &b result_wrapper.result end end
_define_method_around(tgt_concern, aop)
click to toggle source
# File lib/lab42/aop/around.rb, line 31 def _define_method_around tgt_concern, aop result = nil tgt_concern.cls.send :define_method, tgt_concern.name do |*a, &b| result_wrapper = Tools.mk_result_wrapper tgt_concern.mthd.bind( self ), tgt_concern.name send aop, result_wrapper, *a, &b result_wrapper.result end end