lib/mushroom/subscriber.rb
# Public: Setter and getter for events
#
# Can be called multiple times to set events on a Subscriber.
#
# Events cannot be inherited by subclassed objects.
#
# Example:
#   class Handler < Mushroom::Subscriber
#     events :start, :on => Server
#     events :stop, :on => [Server, Time]
#     events :register, :activate, :on => [User]
#   end
#
# Returns: Array of current event registrations.
Setter and getter for events
Can be called multiple times to set events on a Subscriber.

Events cannot be inherited by subclassed objects.



Array of current event registrations.
Setter and getter for events Can be called multiple times to set events on a Subscriber . Events cannot be inherited by subclassed objects . Array of current event registrations .
def create_event_subscription(*events_and_options)
        options = {
          :on => nil
        }.update(events_and_options.extract_options!)
        targets = Array(options[:on]) || raise(ArgumentError, "Event subscription must include :on => Class")
        targets.each do |target|
          events_and_options.each do |event|
            event = Mushroom.event_name(event, target)
            ActiveSupport::Notifications.subscribe(event) do |*args|
              self.notify(ActiveSupport::Notifications::Event.new(*args))
            end
            (self._events ||=[]).push(event)
          end
        end
        return self._events
      end
def create_event_subscription ( * events_and_options ) options = { :on => nil } . update ( events_and_options . extract_options! ) targets = Array ( options [ :on ] ) || raise ( ArgumentError , "Event subscription must include :on => Class" ) targets . each do | target | events_and_options . each do | event | event = Mushroom . event_name ( event , target ) ActiveSupport :: Notifications . subscribe ( event ) do | * args | self . notify ( ActiveSupport :: Notifications :: Event . new ( * args ) ) end ( self . _events ||= [ ] ) . push ( event ) end end return self . _events end
Public: Setter and getter for events
Can be called multiple times to set events on a Subscriber.
Public : Setter and getter for events Can be called multiple times to set events on a Subscriber .
# Actually subscribe the event
events_and_options
<not_specific>