0.0
No commit activity in last 3 years
No release in over 3 years
Class ancestors are taken in consideration.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

class-callbacks

Class callbacks allow creation of ruby class methods that can capture and execute blocks, considering class ancestors.

Installation

to install

gem install class-callbacks

or in Gemfile

gem 'class-callbacks'

and to use

require 'class-callbacks'

How to use

Common usage is to use it to define before and after filters in non-rails environments.

require 'class-callbacks'

class ComeClass
  include ClassCallbacks

  define_callback :before
end

class SomeOtherClass < ComeClass
  before do
    @var = [:foo]
  end
end

class EvenOtherClass < SomeOtherClass
  before :add_more, :add_even_more

  def test
    run_callback :before # @var = [:foo, :bar, :baz]
  end

  private

  def add_more
    @var.push :bar
  end

  def add_even_more
    @var.push :baz
  end
end

Dependency

none

Development

After checking out the repo, run bundle install to install dependencies. Then, run rspec to run the tests.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dux/view-cell. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.