Class: Plugin::RecordModifierOutput::DynamicExpander
- Inherits:
-
Object
- Object
- Plugin::RecordModifierOutput::DynamicExpander
- Defined in:
- lib/fluent/plugin/out_record_modifier.rb
Instance Attribute Summary collapse
-
#param_value ⇒ Object
readonly
Returns the value of attribute param_value.
Instance Method Summary collapse
-
#expand(tag, time, record, tag_parts) ⇒ Object
Default implementation for fixed value.
-
#initialize(param_key, param_value, prepare_value) ⇒ DynamicExpander
constructor
A new instance of DynamicExpander.
Constructor Details
#initialize(param_key, param_value, prepare_value) ⇒ DynamicExpander
Returns a new instance of DynamicExpander.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/fluent/plugin/out_record_modifier.rb', line 200 def initialize(param_key, param_value, prepare_value) if param_value.include?('${') __str_eval_code__ = parse_parameter(param_value) # Use class_eval with string instead of define_method for performance. # It can't share instructions but this is 2x+ faster than define_method in filter case. # Refer: http://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html (class << self; self; end).class_eval <<-EORUBY, __FILE__, __LINE__ + 1 def expand(tag, time, record, tag_parts) #{__str_eval_code__} end EORUBY else @param_value = param_value end begin eval prepare_value if prepare_value rescue SyntaxError raise ConfigError, "Pass invalid syntax parameter : key = prepare_value, value = #{prepare_value}" end begin # check eval genarates wrong code or not (nil, nil, nil, nil) rescue SyntaxError raise ConfigError, "Pass invalid syntax parameter : key = #{param_key}, value = #{param_value}" rescue # Ignore other runtime errors end end |
Instance Attribute Details
#param_value ⇒ Object (readonly)
Returns the value of attribute param_value.
198 199 200 |
# File 'lib/fluent/plugin/out_record_modifier.rb', line 198 def param_value @param_value end |
Instance Method Details
#expand(tag, time, record, tag_parts) ⇒ Object
Default implementation for fixed value. This is overwritten when parameter contains ‘$xxx’ placeholder
233 234 235 |
# File 'lib/fluent/plugin/out_record_modifier.rb', line 233 def (tag, time, record, tag_parts) @param_value end |