Skip to content

Commit bfcf07b

Browse files
committed
docs: clarify usage for Bundler apps vs standalone scripts
1 parent 8584d91 commit bfcf07b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ gem install callable-mixin
3232

3333
## Usage
3434

35-
Simply include Callable in your class and implement an instance method named `call`:
35+
### In a Bundler-based app (Rails, Hanami, etc.)
36+
37+
Simply include `Callable` in your class and implement an instance method named `call`:
3638

3739
```ruby
3840
class SendNotification
@@ -49,6 +51,27 @@ class SendNotification
4951
end
5052
```
5153

54+
### In a plain Ruby script
55+
56+
Require `'callable'`, include `Callable` in your class and implement an instance method named `call`:
57+
58+
```ruby
59+
require 'callable'
60+
61+
class SendNotification
62+
include Callable
63+
64+
def initialize(user, message)
65+
@user = user
66+
@message = message
67+
end
68+
69+
def call
70+
NotificationMailer.notify(@user, @message).deliver_now
71+
end
72+
end
73+
```
74+
5275
Then run your class using the `.call` class method:
5376

5477
```ruby

0 commit comments

Comments
 (0)