File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ gem install callable-mixin
32
32
33
33
## Usage
34
34
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 ` :
36
38
37
39
``` ruby
38
40
class SendNotification
@@ -49,6 +51,27 @@ class SendNotification
49
51
end
50
52
```
51
53
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
+
52
75
Then run your class using the ` .call ` class method:
53
76
54
77
``` ruby
You can’t perform that action at this time.
0 commit comments