Module: Clamp::Option::StrictDeclaration
- Includes:
- Attribute::Declaration, LogStash::Util::Loggable
- Included in:
- StrictCommand
- Defined in:
- lib/logstash/patches/clamp.rb
Instance Method Summary collapse
- #define_appender_for(option) ⇒ Object
- #define_deprecated_accessors_for(option, opts, &block) ⇒ Object
- #define_deprecated_writer_for(option, opts, &block) ⇒ Object
- #define_reader_for(option) ⇒ Object
-
#define_simple_writer_for(option, &block) ⇒ Object
Instead of letting Clamp set up accessors for the options weŕe going to tightly controlling them through LogStash::SETTINGS.
Instance Method Details
#define_appender_for(option) ⇒ Object
51 52 53 54 55 |
# File 'lib/logstash/patches/clamp.rb', line 51 def define_appender_for(option) define_method(option.append_method) do |value| LogStash::SETTINGS.get_value(option.attribute_name) << value end end |
#define_deprecated_accessors_for(option, opts, &block) ⇒ Object
57 58 59 |
# File 'lib/logstash/patches/clamp.rb', line 57 def define_deprecated_accessors_for(option, opts, &block) define_deprecated_writer_for(option, opts, &block) end |
#define_deprecated_writer_for(option, opts, &block) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/logstash/patches/clamp.rb', line 61 def define_deprecated_writer_for(option, opts, &block) define_method(option.write_method) do |value| self.class.logger.warn "DEPRECATION WARNING: The flag #{option.switches} has been deprecated, please use \"--#{opts[:new_flag]}=#{opts[:new_value]}\" instead." LogStash::SETTINGS.set(opts[:new_flag], opts[:new_value]) end end |
#define_reader_for(option) ⇒ Object
45 46 47 48 49 |
# File 'lib/logstash/patches/clamp.rb', line 45 def define_reader_for(option) define_method(option.read_method) do LogStash::SETTINGS.get_value(option.attribute_name) end end |
#define_simple_writer_for(option, &block) ⇒ Object
Instead of letting Clamp set up accessors for the options weŕe going to tightly controlling them through LogStash::SETTINGS
37 38 39 40 41 42 43 |
# File 'lib/logstash/patches/clamp.rb', line 37 def define_simple_writer_for(option, &block) LogStash::SETTINGS.get(option.attribute_name) define_method(option.write_method) do |value| value = instance_exec(value, &block) if block LogStash::SETTINGS.set_value(option.attribute_name, value) end end |