module Lab42::AOP::ParamFilter

Public Instance Methods

with_block(rcv, tgts, **kwds, &blk) click to toggle source
# File lib/lab42/aop/param_filter.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_param_filter tgt_concern, blk
  end
end
with_methods(rcv, tgts, aops, **kwds) click to toggle source
# File lib/lab42/aop/param_filter.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_param_filter tgt_concern, aop
    end
  end
end

Private Instance Methods

_define_block_param_filter(tgt_concern, blk) click to toggle source
# File lib/lab42/aop/param_filter.rb, line 21
def _define_block_param_filter tgt_concern, blk
  tgt_concern.cls.send :define_method, tgt_concern.name do |*a, &b|
    new_params = blk.(*a)
    tgt_concern.mthd.bind( self ).( *new_params, &b )
  end
end
_define_method_param_filter(tgt_concern, aop) click to toggle source
# File lib/lab42/aop/param_filter.rb, line 28
def _define_method_param_filter tgt_concern, aop
  tgt_concern.cls.send :define_method, tgt_concern.name do |*a, &b|
    new_params = send( aop, *a )
    tgt_concern.mthd.bind( self ).( *new_params, &b )
  end
end