Skip to content

teejayvanslyke/gazer

Repository files navigation

gazer

DESCRIPTION:

Poor man’s aspect-oriented programming for Ruby.

FEATURES/PROBLEMS:

  • Elegant DSL

  • before & after pointcuts.

  • Rails integration.

ROADMAP:

  • Locking down Object monkeypatching scheme.

  • Mutations API to allow accessing methods at any point in their mutation lifecycle.

  • More selectors and pointcuts.

  • Regular-expression-based pointcuts.

  • :only and except options for Rails helper.

SYNOPSIS:

Gazer’s DSL is accessible to subclasses of Gazer::Aspect::Base.

class LoggingAspect < Gazer::Aspect::Base

  before instances_of(Article) => :create do |point|
    puts "Creating article"
  end

  after instances_of([Article, Comment]) => :save do |point|
    puts "Saved #{point.object}."
  end

end

I have also provided a Rails generator for generating aspects for your project. Simply execute the following:

$ script/generate aspect logging

A template will be created at app/aspects/logging_aspect.rb for your aspect-oriented pleasure.

To include an aspect for a given controller, use the aspect class method:

class MyController < ApplicationController
  aspect :logging
end

INSTALL:

$ sudo gem install teejayvanslyke-gazer

LICENSE:

(The MIT License)

Copyright © 2009 T.J. VanSlyke

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

poor man's aspect-oriented ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages