Module: AspectR

Defined in:
lib/aspectr.rb

Overview

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: [email protected]

Copyright © 2001 Avi Bryant ([email protected]) and Robert Feldt ([email protected]).

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

Defined Under Namespace

Classes: Aspect, AspectRException

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.wrap_classes(aspect, pre, post, classes, *methods) ⇒ Object

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



290
291
292
293
# 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

Instance Method Details

#all_classes(regexp = /^.+$/) ⇒ Object

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!



300
301
302
303
304
305
306
# 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