Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dux/class-callbacks
Class callbacks allow creation of ruby class methods that can capture and execute blocks, considering class ancestors.
https://github.com/dux/class-callbacks
Last synced: about 2 months ago
JSON representation
Class callbacks allow creation of ruby class methods that can capture and execute blocks, considering class ancestors.
- Host: GitHub
- URL: https://github.com/dux/class-callbacks
- Owner: dux
- License: mit
- Created: 2021-02-25T17:45:14.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-25T17:45:54.000Z (almost 4 years ago)
- Last Synced: 2024-04-24T21:43:18.192Z (9 months ago)
- Language: Ruby
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this 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.
```ruby
require 'class-callbacks'class ComeClass
include ClassCallbacksdefine_callback :before
endclass SomeOtherClass < ComeClass
before do
@var = [:foo]
end
endclass EvenOtherClass < SomeOtherClass
before :add_more, :add_even_moredef test
run_callback :before # @var = [:foo, :bar, :baz]
endprivate
def add_more
@var.push :bar
enddef 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](http://contributor-covenant.org) code of conduct.## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).