Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yieldhelper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yieldhelper

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Yieldhelper

I hope you enjoy yield_helper. This came about while refactoring a bunch of yielding methods of another gem I was working on.

Installation

Add this line to your application's Gemfile:

gem 'yieldhelper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yieldhelper

Usage

This works with either a method or a stand alone function. See the testbench file in the spec directory for some examples. The one-liner looks like this:

return Enumerator.enumerate_yields(self, :my_method_name, first_parameter, second_parameter, etc) unless block_given?

The first parameter is always self, the second parameter is a symbol of your method name. This is followed by your parameter list if any. This one-liner is typically the first line in your method.

The one-liner will only execute if no block is given (via the unless block_given?); in this case, the enumerate_yields class method will recursively call your method (named in the second parameter). The return statement prevents fall-through when the recursion ends; it also gives you an enumerator object instance. All you need to do is a simple copy-paste-edit on the above one-liner.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Don't think this will ever change, so for now I will deal with it alone.

License

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

FAQs

Package last updated on 07 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc