https://github.com/yegor256/obk
Ruby decorator to throttle object method calls: there will be fixed delays between them
https://github.com/yegor256/obk
ruby ruby-gem
Last synced: about 1 year ago
JSON representation
Ruby decorator to throttle object method calls: there will be fixed delays between them
- Host: GitHub
- URL: https://github.com/yegor256/obk
- Owner: yegor256
- License: mit
- Created: 2021-03-07T07:42:08.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T10:54:22.000Z (over 1 year ago)
- Last Synced: 2024-09-16T12:27:49.372Z (over 1 year ago)
- Topics: ruby, ruby-gem
- Language: Ruby
- Homepage: https://rubygems.org/gems/obk
- Size: 93.8 KB
- Stars: 10
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Throttle Ruby Method Calls
[](https://www.elegantobjects.org)
[](http://www.rultor.com/p/yegor256/obk)
[](https://www.jetbrains.com/ruby/)
[](https://github.com/yegor256/obk/actions/workflows/rake.yml)
[](https://codecov.io/github/yegor256/obk?branch=master)
[](http://badge.fury.io/rb/obk)
[](https://codeclimate.com/github/yegor256/obk/maintainability)
[](http://rubydoc.info/github/yegor256/obk/master/frames)
[](https://hitsofcode.com/view/github/yegor256/obk)
[](https://github.com/yegor256/obk/blob/master/LICENSE.txt)
First, install it:
```bash
gem install obk
```
Then, use it like this:
```ruby
require 'obk'
obj = Obk.new(obj, pause: 500)
obj.foo
# Forced 500ms delay here
obj.bar
```
There will be a forced delay of 500 milliseconds between `.foo` and `.bar` calls.
Keep in mind that `Obk` is _not_ thread-safe.
## How to contribute
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
Make sure your build is green before you contribute
your pull request. You will need to have
[Ruby](https://www.ruby-lang.org/en/) 2.3+ and
[Bundler](https://bundler.io/) installed. Then:
```bash
bundle update
bundle exec rake
```
If it's clean and you don't see any error messages, submit your pull request.