module AspectR

AspectR - simple Aspect-Oriented Programming (AOP) in Ruby. Version 0.3.6, 2006-03-11. NOTE! API has changed somewhat from 0.2 so beware! Last modification: Benjamin Alterauge Email: benjamin_alterauge@web.de

Copyright © 2001 Avi Bryant (avi@beta4.com) and Robert Feldt (feldt@ce.chalmers.se).

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Public Class Methods

wrap_classes(aspect, pre, post, classes, *methods) click to toggle source

NOTE! Somewhat experimental so API will likely change on this method!

# File lib/aspectr.rb, line 290
def wrap_classes(aspect, pre, post, classes, *methods)
  classes = all_classes(classes) if classes.kind_of?(Regexp)
  classes.each {|klass| aspect.wrap(klass, pre, post, *methods)}
end

Public Instance Methods

all_classes(regexp = /^.+$/) click to toggle source

TODO: Speed this up by recursing from Object.constants instead of sifting through all object in the ObjectSpace (might be slow if many objects). Is there a still faster/better way? NOTE! Somewhat experimental so API will likely change on this method!

# File lib/aspectr.rb, line 300
def all_classes(regexp = /^.+$/)
  classes = []
  ObjectSpace.each_object(Class) do |c|
    classes.push c if c.inspect =~ regexp
  end
  classes
end

Private Instance Methods

wrap_classes(aspect, pre, post, classes, *methods) click to toggle source

NOTE! Somewhat experimental so API will likely change on this method!

# File lib/aspectr.rb, line 290
def wrap_classes(aspect, pre, post, classes, *methods)
  classes = all_classes(classes) if classes.kind_of?(Regexp)
  classes.each {|klass| aspect.wrap(klass, pre, post, *methods)}
end