[Nitro] Problem with aspects (in Facets).

George Moschovitis george.moschovitis at gmail.com
Mon Feb 5 14:08:58 EST 2007


While trying to make the no-eval sql.rb patch to work I found out that
Aspects#wrap did not work as expected (at least for methods with default
parameters, due to the way that airty works in Ruby). Here is a fix:

  def self.wrap(target, methods = target.instance_methods)
    include_advice_modules(target)

    for m in [methods].flatten
      target.module_eval <<-end_eval, __FILE__, __LINE__
        alias_method :__unwrapped_#{m}, :#{m}
        def #{m}(*args)
          #{gen_advice_code(m, target.advices, :pre)}
          __unwrapped_#{m}(*args)
          #{gen_advice_code(m, target.advices, :post)}
        end
      end_eval
    end
  end

this seems to work... But, I would like to ask Tom to have a look at the
Aspects implementation and perhaps work his magic on a better solution.
In the meantime please include this fix in facets/more/aspects.rb


-g.



-- 
http://blog.gmosx.com
http://cull.gr
http://www.joy.gr
http://nitroproject.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20070205/733d2256/attachment.html 


More information about the Nitro-general mailing list