Class: FluQ::Handler::Base

Inherits:
Object
  • Object
show all
Includes:
Mixins::Loggable
Defined in:
lib/fluq/handler/base.rb

Direct Known Subclasses

Log, Noop, Test

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Loggable

#logger

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.

Examples:


class MyHandler < FluQ::Handler::Base
end
MyHandler.new

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :name (String)

    a (unique) handler identifier



25
26
27
28
# File 'lib/fluq/handler/base.rb', line 25

def initialize(options = {})
  @config  = defaults.merge(options)
  @name    = config[:name] || self.class.type
end

Instance Attribute Details

#configObject (readonly)



15
16
17
# File 'lib/fluq/handler/base.rb', line 15

def config
  @config
end

#nameObject (readonly)



12
13
14
# File 'lib/fluq/handler/base.rb', line 12

def name
  @name
end

Class Method Details

.typeString

Returns handler type.

Returns:

  • (String)

    handler type



7
8
9
# File 'lib/fluq/handler/base.rb', line 7

def self.type
  @type ||= name.split("::")[-1].downcase
end

Instance Method Details

#filter(events) ⇒ Array<FluQ::Event>

Returns filtered events.

Parameters:

Returns:



32
33
34
# File 'lib/fluq/handler/base.rb', line 32

def filter(events)
  events
end

#on_events(events) ⇒ Object

This method is abstract.

callback, called on each event

Parameters:



43
44
# File 'lib/fluq/handler/base.rb', line 43

def on_events(events)
end

#timersTimers

Returns timers.

Returns:

  • (Timers)

    timers



37
38
39
# File 'lib/fluq/handler/base.rb', line 37

def timers
  @timers ||= Timers.new
end