rails/rails — pull request #6093 by marcandre (2012-04-30 18:30:22+00:00)
Title: notify_observers should be public

As @twinturbo objected in pull request #6063, here's a separate request for this change and expanded reasoning.

Reasons to make `notify_observers` public:

- consistent with the fact that `notify_observers` in the stdlib's `Observable` is public.
- consistent with the fact that the singleton method `notify_observers` is public:

Foo.notify_observers(:my_event, the_foo) # => currently ok
the_foo.notify_observers(:my_event) # => currently not ok

- `notify_observers` is not the right level to restrict access. Some actions would be best kept private (say :after_save) but custom actions could very well be triggered by external clients. The class and its instances simply act as a rendez-vous point where complete strangers to the class can communicate.

Example:

An observer implements `:after_save` to detect some state change. If detected, it wants to send a custom notification `:some_state_changed`, so other observers can be notified and don't have to reimplement the state change logic. It shouldn't have to use `send`.

Thanks