Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Salazar committed Jul 1, 2014
1 parent b5e6794 commit eb1a676
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ end
```

This will define an instance method named `:get_data` and rescue the exception
`ApiError` and retry the block
`ApiError` and retry the block:

```ruby
do
do_api_call
end
```
3 times (the default)
3 times (the default).

### Retrying a block of code

Expand All @@ -55,7 +55,7 @@ class ApiWrapper
def get_data
@some_state = 'start'

retry on: ApiError do
retryable on: ApiError do
@some_state = 'working'
do_api_call
end
Expand All @@ -70,11 +70,11 @@ This will retry just that block of code.
### Options

These apply to both `.def_retry` and `#retry`:
- on: a single class or an array of exception classes to be rescued
- tries: Integer number of maximum retries to run. DefRetry will stop retrying if the retry cound reaches this number
- sleep: Either a Proc that receives the current try count as its only argument or a Symbol naming one of these sleep strategies: constant, linear, exponential
- on_retry: a callback to run everytime a retry happens i.e. the specified expception(s) are rescued
- on_ensure: "a callback to run at the end before returning the block's value"
- `:on`: a single class or an array of exception classes to be rescued
- `:tries`: Integer number of maximum retries to run. DefRetry will stop retrying if the retry cound reaches this number
- `:sleep`: Either a Proc that receives the current try count as its only argument or a Symbol naming one of these sleep strategies: constant, linear, exponential
- `:on_retry`: a callback to run everytime a retry happens i.e. the specified expception(s) are rescued
- `:on_ensure`: "a callback to run at the end before returning the block's value"

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion lib/def_retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def def_retry(name, options = {}, &block)
end

module InstanceMethods
def retry(options = {}, &block)
def retryable(options = {}, &block)
DefRetry.retry options, &block
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/def_retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class MockRetryable
end
end

context '#retry' do
context '#retryable' do
it "returns the block's value" do
mocked = mock_retryable.new
expect(mocked.retry(on: Exception) { 2 + 2 }).to be 4
expect(mocked.retryable(on: Exception) { 2 + 2 }).to be 4
end
end
end
Expand Down

0 comments on commit eb1a676

Please sign in to comment.