Class: Fluent::Config::DSL::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/config/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, arg, include_basepath = Dir.pwd) ⇒ Proxy

Returns a new instance of Proxy.



38
39
40
41
# File 'lib/fluent/config/dsl.rb', line 38

def initialize(name, arg, include_basepath = Dir.pwd)
  @element = Element.new(name, arg, self)
  @include_basepath = include_basepath
end

Instance Method Details

#add_element(name, arg, block) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/fluent/config/dsl.rb', line 62

def add_element(name, arg, block)
  ::Kernel.raise ::ArgumentError, "#{name} block must be specified" if block.nil?

  proxy = self.class.new(name.to_s, arg)
  proxy.element.instance_exec(&block)

  @element.instance_eval do
    @elements.push(proxy.to_config_element)
  end

  self
end

#elementObject



43
44
45
# File 'lib/fluent/config/dsl.rb', line 43

def element
  @element
end

#eval(source, source_path) ⇒ Object



51
52
53
54
# File 'lib/fluent/config/dsl.rb', line 51

def eval(source, source_path)
  @element.instance_eval(source, source_path)
  self
end

#include_basepathObject



47
48
49
# File 'lib/fluent/config/dsl.rb', line 47

def include_basepath
  @include_basepath
end

#to_config_elementObject



56
57
58
59
60
# File 'lib/fluent/config/dsl.rb', line 56

def to_config_element
  @element.instance_eval do
    Config::Element.new(@name, @arg, @attrs, @elements)
  end
end