Class: LogStash::Config::AST::PluginSection
- Inherits:
-
Node
- Object
- Treetop::Runtime::SyntaxNode
- Node
- LogStash::Config::AST::PluginSection
- Defined in:
- lib/logstash/config/config_ast.rb
Constant Summary collapse
- @@i =
0
Instance Method Summary collapse
-
#compile_initializer ⇒ Object
Generate ruby code to initialize all the plugins.
- #generate_variables ⇒ Object
- #variable(object) ⇒ Object
Instance Method Details
#compile_initializer ⇒ Object
Generate ruby code to initialize all the plugins.
89 90 91 92 93 94 95 96 97 |
# File 'lib/logstash/config/config_ast.rb', line 89 def compile_initializer generate_variables code = [] @variables.collect do |plugin, name| code << "#{name} = #{plugin.compile_initializer}" code << "@#{plugin.plugin_type}s << #{name}" end return code.join("\n") end |
#generate_variables ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/logstash/config/config_ast.rb', line 104 def generate_variables return if !@variables.nil? @variables = {} plugins = recursive_select(Plugin) plugins.each do |plugin| # Unique number for every plugin. @@i += 1 # store things as ivars, like @filter_grok_3 var = "@#{plugin.plugin_type}_#{plugin.plugin_name}_#{@@i}" @variables[plugin] = var end return @variables end |
#variable(object) ⇒ Object
99 100 101 102 |
# File 'lib/logstash/config/config_ast.rb', line 99 def variable(object) generate_variables return @variables[object] end |