module Lab42::AOP::CrossConcern

Public Instance Methods

get_methods(cls, mthd_specs, **kwds) click to toggle source
# File lib/lab42/aop/cross_concern.rb, line 6
def get_methods cls, mthd_specs, **kwds 
  mthd_specs
  .map{ |ms| _get_methods cls, ms, **kwds }
  .flatten
  .compact
  .uniq
end

Private Instance Methods

_exclude_candidates(candidates, exclude) click to toggle source
# File lib/lab42/aop/cross_concern.rb, line 15
def _exclude_candidates candidates, exclude
  case exclude
  when Array
    candidates - exclude
  when Symbol
    candidates - Array( exclude )
  when Regexp
    candidates - candidates.grep( exclude )
  end
end
_get_methods(cls, mthd_spec, include_included: false, exclude: nil) click to toggle source
# File lib/lab42/aop/cross_concern.rb, line 25
def _get_methods cls, mthd_spec, include_included: false, exclude: nil
  candidates = _get_methods_candidates cls, mthd_spec, include_included: include_included
  candidates = _exclude_candidates( candidates, exclude ) if exclude
  _make_concerns( cls, candidates )
end
_get_methods_candidates(cls, mthd_spec, include_included: false) click to toggle source
# File lib/lab42/aop/cross_concern.rb, line 31
def _get_methods_candidates cls, mthd_spec, include_included: false
  case mthd_spec
  when Symbol
    [ mthd_spec ]
  when String
    cls
    .instance_methods( include_included )
    .grep( %r{#{mthd_spec}} )
  when Regexp
    cls
    .instance_methods( include_included )
    .grep( mthd_spec )
  when Module
    mthd_spec
    .instance_methods( include_included )
  end
end
_make_concern(cls, mthd_spec) click to toggle source
# File lib/lab42/aop/cross_concern.rb, line 52
def _make_concern cls, mthd_spec
  OpenStruct.new cls: cls, name: mthd_spec, mthd: cls.instance_method( mthd_spec ) 
rescue
  nil
end
_make_concerns(cls, mss) click to toggle source
# File lib/lab42/aop/cross_concern.rb, line 49
def _make_concerns cls, mss
  mss.map{ |ms| _make_concern cls, ms }
end