Class: FluQ::DSL::Root

Inherits:
Base
  • Object
show all
Defined in:
lib/fluq/dsl/root.rb

Overview

Root-level DSL configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Root

Returns a new instance of Root.

Parameters:

  • DSL (String)

    script file path



6
7
8
9
10
11
# File 'lib/fluq/dsl/root.rb', line 6

def initialize(path)
  @path   = Pathname.new(path)
  @feeds  = []

  instance_eval @path.read
end

Instance Attribute Details

#feedsObject (readonly)

Returns the value of attribute feeds.



3
4
5
# File 'lib/fluq/dsl/root.rb', line 3

def feeds
  @feeds
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/fluq/dsl/root.rb', line 3

def path
  @path
end

Instance Method Details

#apply(runner) ⇒ Object

Applies the configuration. Registers components of each feed. Handlers first, then inputs.

Parameters:



26
27
28
29
30
31
32
33
# File 'lib/fluq/dsl/root.rb', line 26

def apply(runner)
  feeds.each do |conf|
    runner.feed conf.name do |feed|
      conf.handlers.each {|k, *a| feed.register(k, *a) }
      conf.inputs.each   {|k, *a| feed.listen(k, *a) }
    end
  end
end

#feed(name, &block) ⇒ Object

Parameters:

  • feed (String)

    name, e.g. “my_events”



14
15
16
# File 'lib/fluq/dsl/root.rb', line 14

def feed(name, &block)
  feeds.push FluQ::DSL::Feed.new(name, &block)
end

#import(relative) ⇒ Object

Parameters:

  • relative (String)

    relative path



19
20
21
# File 'lib/fluq/dsl/root.rb', line 19

def import(relative)
  instance_eval path.dirname.join(relative).read
end