No Backsies

Homepage | Development | Mailing List | API Reference | Demonstrandum

DESCRIPTION

NoBacksies 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.

Compatability

NoBacksies does not currently work with Rubinius. Anyone know why?

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

CONTRIBUTE

Development

Source code is hosted on GitHub. If you’d like to submit a patch please fork the repository and submit a pull request (ideally in a topic branch).

Testing

QED is used to testing.

$ gem install qed

To run the tests:

$ qed [path/to/test]

Donations

Software development is very time consuming. Rubyworks does a lot of FOSS development for el $0. We do it for the love of programming and for Ruby. Any dollars that do come our way help us continue the effort. So anything you may offer will help these projects such as this continue to flourish.

See the Rubyworks Homepage.

Thanks.

(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.