public
Description: Super-simple implementation of Aspects for Ruby
Homepage:
Clone URL: git://github.com/matthewrudy/aspicious.git
Matthew Rudy Jacobs (author)
Sun Dec 14 14:31:03 -0800 2008
commit  40e42ceaa6c8da1c166f924dd61c02bde6045c71
tree    0cebd38b17e1d8eee9ca136dd27e6a22cc470954
parent  483f45f7cce9c1b38bec035ca5c84fc12e824dc0
name age message
file README Sat Dec 06 17:57:23 -0800 2008 add the gem require commands to the Aspicious e... [matthewrudy]
file Rakefile Sat Dec 06 17:28:24 -0800 2008 moved to a more proper structure [matthewrudy]
file aspicious.gemspec Sun Dec 07 15:32:08 -0800 2008 bump the version to 0.1.1 [matthewrudy]
directory examples/ Sat Dec 06 17:28:24 -0800 2008 moved to a more proper structure [matthewrudy]
directory lib/ Sun Dec 14 14:31:03 -0800 2008 use the new "it:" directive for doctests [Matthew Rudy Jacobs]
directory rdoc/ Sun Dec 14 13:53:02 -0800 2008 more doctests and re-rdoc [Matthew Rudy Jacobs]
README
Aspicious
=====================================================

Aspicious is a lightweight, simple, implementation of Aspects into Ruby.
For a more heavy handed approach see AspectR and Aquarium.

Aspicious is based on the founding principle that "aspects" is like "suspects"
and "aspicious" is like "suspicious". So it doesnt mean anything, but nevertheless is a name.

Example
=====================================================
  require 'rubygems'
  require 'aspicious'

  class Turtle < ActiveRecord::Base
    def lay_some_eggs
      puts "laying these eggs good"
    end
  end

  class EggThief < Aspicious::Watcher
    watch Turtle
    after :lay_some_eggs, :try_to_steal_the_eggs

    def try_to_steal_the_eggs
      if watchee.is_weak?
        puts "I stole the eggs"
      else
        puts "I didnt manage to steal the eggs. Nature is safe!"
      end
    end
  end

but you can also "watch" multiple classes, and specify an :only option

  class Chicken
    def lay_some_eggs
      puts "chickens lay eggs for everybody to eat"
    end
  end

  class CorporateEggFarmer < Aspicious::Watcher
    watch Turtle, Chicken
    before :lay_some_eggs, :advertise_the_eggs, :only => Chicken

    def advertise_the_eggs
      puts "even though #{watchee.name}'s eggs aren't out yet, I'll start advertising them on TV. If Kerry Katona is 
      advertising them on ITV they will surely sell?"
    end
  end

BOOM!!!
Most of the power of Aspect Oriented Programming for 1% of the price

Copyright (c) 2008 [Matthew Rudy Jacobs], released under the MIT license