0.0
No commit activity in last 3 years
No release in over 3 years
PassAttempt run a block depending on a custom proc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.7
~> 5.0
~> 10.0
 Project Readme

PassAttempt

PassAttempt run a block depending on a condition.

Super simple Singleton with counter by name, that process a block. when condition is true.

I wrote this gem in order to avoid fill my exception_notification service.

Installation

Add this line to your application's Gemfile:

gem 'pass_attempt'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pass_attempt

Usage

name = 'my_filtred_acction'
condition = ->(attempts) { attempts.odd? }

(1..4).each do |i|
  PassAttempt.try(name, condition) do
    puts "my_filtred_acction #{i}"
  end
end

my_filtred_acction 1
my_filtred_acction 3

Condition can be a proc that receive counter for name and return boolean. Also condition can be a symbol (:log2 or :log10), to be used as test of counter of name.

Contributing

  1. Fork it ( https://github.com/alejandrobabio/pass_attempt/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request