Class: Manufactured::EventHandler

Inherits:
Omega::Server::EventHandler show all
Defined in:
lib/manufactured/event_handler.rb

Overview

Subclasses Omega::Server::EventHandler to define a custom event handler with more granular event matching

Instance Attribute Summary collapse

Attributes inherited from Omega::Server::EventHandler

#endpoint_id, #event_id, #event_type, #handlers, #persist

Instance Method Summary collapse

Methods inherited from Omega::Server::EventHandler

#exec, #handlers_json, #invoke, json_create, #json_data

Constructor Details

#initialize(args = {}) ⇒ EventHandler


16
17
18
19
# File 'lib/manufactured/event_handler.rb', line 16

def initialize(args={})
  attr_from_args args, :event_args => []
  super(args)
end

Instance Attribute Details

#event_argsObject

Returns the value of attribute event_args


14
15
16
# File 'lib/manufactured/event_handler.rb', line 14

def event_args
  @event_args
end

Instance Method Details

#matches?(event) ⇒ Boolean


21
22
23
# File 'lib/manufactured/event_handler.rb', line 21

def matches?(event)
  super(event) && event.trigger_handler?(self)
end

#to_json(*a) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/manufactured/event_handler.rb', line 25

def to_json(*a)
  { 'json_class' => self.class.name,
    'data'       =>
      json_data.merge({:event_args => event_args,
                       :handlers => handlers})
  }.to_json(*a)
end