Skip to content

Commit

Permalink
Update Event guides
Browse files Browse the repository at this point in the history
Documenting automatic loading of files and subscription
of subscribers when their files are placed under the
directory `app/subscribers` and end with `_subscriber.rb`
  • Loading branch information
spaghetticode committed Mar 30, 2020
1 parent 1e1b88b commit 60f7746
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions guides/source/developers/events/overview.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ method allows to map a method of the subscriber module to an event that
happens in the system. If the `event_name` argument is not specified,
the event name and the method name should match.

These subscribers modules are loaded with the rest of your application but
you need to manually subscribe to them.
These subscriber modules are loaded with the rest of your application, you
don't need to manually subscribe them when:

For example, you could subscribe to them programmatically with something like:
* you put them in the directory (or any subdirectory of) `app/subscribers`
* their filename ends with `_subscriber.rb`

On the other hand, if you need to resort to manual subscription because you did
not follow the naming convetion explained above, you can use an initializer
in order to subscribe your subscribers, for example with something similar to:

```ruby
if defined?(SmsLibrary)
Expand Down

0 comments on commit 60f7746

Please sign in to comment.