Module: Clamp::Option::StrictDeclaration

Includes:
Attribute::Declaration, LogStash::Util::Loggable
Included in:
StrictCommand
Defined in:
lib/logstash/patches/clamp.rb

Instance Method Summary collapse

Methods included from LogStash::Util::Loggable

included, #logger, #slow_logger

Instance Method Details

#define_deprecated_accessors_for(option, opts, &block) ⇒ Object



51
52
53
# File 'lib/logstash/patches/clamp.rb', line 51

def define_deprecated_accessors_for(option, opts, &block)
  define_deprecated_writer_for(option, opts, &block)
end

#define_deprecated_writer_for(option, opts, &block) ⇒ Object



55
56
57
58
59
60
# File 'lib/logstash/patches/clamp.rb', line 55

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