Class: FluQ::Handler::Base
- Inherits:
-
Object
- Object
- FluQ::Handler::Base
- Includes:
- Mixins::Loggable
- Defined in:
- lib/fluq/handler/base.rb
Instance Attribute Summary collapse
- #config ⇒ Object readonly
- #name ⇒ Object readonly
- #pattern ⇒ Object readonly
- #reactor ⇒ Object readonly
Class Method Summary collapse
-
.type ⇒ String
Handler type.
Instance Method Summary collapse
-
#initialize(reactor, options = {}) ⇒ Base
constructor
A new instance of Base.
-
#match?(event) ⇒ Boolean
True if event matches.
- #on_events(events) ⇒ Object abstract
-
#select(events) ⇒ Array<FluQ::Event>
Matching events.
Methods included from Mixins::Loggable
Constructor Details
#initialize(reactor, options = {}) ⇒ Base
Returns a new instance of Base.
32 33 34 35 36 37 |
# File 'lib/fluq/handler/base.rb', line 32 def initialize(reactor, = {}) @reactor = reactor @config = defaults.merge() @name = config[:name] || generate_name @pattern = generate_pattern end |
Instance Attribute Details
#config ⇒ Object (readonly)
18 19 20 |
# File 'lib/fluq/handler/base.rb', line 18 def config @config end |
#name ⇒ Object (readonly)
15 16 17 |
# File 'lib/fluq/handler/base.rb', line 15 def name @name end |
#pattern ⇒ Object (readonly)
21 22 23 |
# File 'lib/fluq/handler/base.rb', line 21 def pattern @pattern end |
#reactor ⇒ Object (readonly)
12 13 14 |
# File 'lib/fluq/handler/base.rb', line 12 def reactor @reactor end |
Class Method Details
.type ⇒ String
Returns 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
#match?(event) ⇒ Boolean
Returns true if event matches.
40 41 42 |
# File 'lib/fluq/handler/base.rb', line 40 def match?(event) !!(pattern =~ event.tag) end |
#on_events(events) ⇒ Object
This method is abstract.
callback, called on each event
52 53 |
# File 'lib/fluq/handler/base.rb', line 52 def on_events(events) end |
#select(events) ⇒ Array<FluQ::Event>
Returns matching events.
46 47 48 |
# File 'lib/fluq/handler/base.rb', line 46 def select(events) events.select {|e| match?(e) } end |