No Backsies

DESCRIPTION

NoBackies is a callback layer built on top of Ruby’s built-in callback methods. It makes it possible to add new callbacks very easily, without having to fuss with more nuanced issues of defining and redefining callback methods.

RESOURCES

EXAMPLES

Here is a very simple example of how NoBacksies works.

class Y
  include NoBacksies::Callbacks

  def self.list
    @list ||= []
  end

  callback :method_added do |method|
    list << method
  end

  def foo; end
  def bar; end
end

Y.list #=> [:foo, :bar]

Here is another example taken from the Anise project.

class Y
  include Anise
  include NoBacksies

  def self.doc(string)
    callback :method_added, :once=>true do |method|
      self.ann(method, :doc=>string)
    end
  end

  doc "foo is cool"
  def foo
    # ...
  end
end

Y.ann(:foo, :doc) #=> "foo is cool"

See the QED documentation for more examples.

INSTALLATION

Install the RubyGems package in the usual fashion.

$ gem install no_backsies

(BSD 2 License)

Copyright © 2011 Thomas Sawyer

Unless otherwise negotiated with the original author, NoBacksies is distributable under the terms of the BSD 2-clause license.

See the LICENSE.rdoc file for details.