class Spine::Hub::Subscriptions::Closure

Subscriber for blocks.

Requirements

Attributes

action[R]
trigger[R]

Public Class Methods

new(event, action) click to toggle source
# File lib/spine/hub/subscriptions/closure.rb, line 12
def initialize(event, action)
  @trigger = event
  @action = action
end

Public Instance Methods

notify(event, *arguments) click to toggle source

Notifies subscriber about event. When event matches with triggering event it executes action.

Attributes

  • event - Name of event.

  • arguments - Arguments for event.

# File lib/spine/hub/subscriptions/closure.rb, line 23
def notify(event, *arguments)
  action.call(*arguments) if trigger?(event)
end
trigger?(event) click to toggle source

Returns true when subscriber is triggered by specified event.

Attributes

  • event - Name of event.

# File lib/spine/hub/subscriptions/closure.rb, line 31
def trigger?(event)
  trigger == event
end