Class: FluQ::DSL::Root
Overview
Root-level DSL configuration
Instance Attribute Summary collapse
-
#feeds ⇒ Object
readonly
Returns the value of attribute feeds.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#apply(runner) ⇒ Object
Applies the configuration.
- #feed(name, &block) ⇒ Object
- #import(relative) ⇒ Object
-
#initialize(path) ⇒ Root
constructor
A new instance of Root.
Constructor Details
#initialize(path) ⇒ Root
Returns a new instance of Root.
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
#feeds ⇒ Object (readonly)
Returns the value of attribute feeds.
3 4 5 |
# File 'lib/fluq/dsl/root.rb', line 3 def feeds @feeds end |
#path ⇒ Object (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.
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
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
19 20 21 |
# File 'lib/fluq/dsl/root.rb', line 19 def import(relative) instance_eval path.dirname.join(relative).read end |