Top Level Namespace
Defined Under Namespace
Modules: Kernel Classes: Aspect, Class, Cut, Joinpoint, Symbol, Target
Instance Method Summary collapse
Instance Method Details
#cross_cut(klass) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/cuts/aop.rb', line 108 def cross_cut(klass) Cut.new(klass) do define_method :__base__ do klass end all_instance_methods.each do |meth| undef_method(meth) unless meth.to_s =~ /(^__|initialize$|p$|class$|inspect$)/ end #def initialize(base, *args, &block) # @base = base # @delegate = base.__new(*args, &block) # @advices = {} #end def method_missing(sym, *args, &blk) # p "METHOD MISSING: #{sym}" #if DEBUG @advices ||= {} base = __base__ jp = Joinpoint.new(self, base, sym, *args, &blk) # calculate advices on first use. unless @advices[sym] @advices[sym] = [] base.aspects.each do |aspect| aspect.points.each do |advice, matches| matches.each do |match| if jp === match @advices[sym] << [aspect, advice] end end end end end target = jp #Target.new(self, sym, *args, &blk) # Target == JoinPoint ? @advices[sym].each do |(aspect, advice)| target = Target.new(aspect, advice, target) end target.super end end end |