0.0
No release in over a year
Evaluate block in first argument. You can use `Module#ensemble(method_name)` method. When you call `ensemble(method_name)`, block passed to `method_name` will be evaluated in the context of the first argument of the block.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

EnsembleCast

Evaluate block in first argument.

This gem is experimental. By manipulating the stack of Ruby implementation, it provides features that is not possible with normal metaprogramming. Do not use in production code.

Installation

Add this line to your application's Gemfile:

gem 'ensemble_cast'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install ensemble_cast

Usage

You can use Module#ensemble(method_name) method.

When you call ensemble(method_name), block passed to method_name will be evaluated in the context of the first argument of the block.

example:

require 'ensemble_cast'

class Array
  ensemble def my_filter
    filter { |e| yield(e) }
  end
end

[-2, -1, 0, 1, 2].my_filter { even? && !negative? }
# => [0, 2]

Contributing

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

License

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

Code of Conduct

Everyone interacting in the EnsembleCast project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.