Class: Fluent::Config::Section
- Inherits:
- BasicObject
- Defined in:
- lib/fluent/config/section.rb
Class Method Summary collapse
Instance Method Summary collapse
- #+(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #class ⇒ Object
- #corresponding_config_element ⇒ Object
- #dup ⇒ Object
-
#initialize(params = {}, config_element = nil) ⇒ Section
constructor
A new instance of Section.
- #inspect ⇒ Object
- #instance_of?(mod) ⇒ Boolean
- #kind_of?(mod) ⇒ Boolean (also: #is_a?)
- #method_missing(name, *args) ⇒ Object
- #nil? ⇒ Boolean
- #respond_to?(symbol, include_all = false) ⇒ Boolean
- #respond_to_missing?(symbol, include_private) ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}, config_element = nil) ⇒ Section
Returns a new instance of Section.
29 30 31 32 33 |
# File 'lib/fluent/config/section.rb', line 29 def initialize(params = {}, config_element = nil) @klass = 'Fluent::Config::Section' @params = params @corresponding_config_element = config_element end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/fluent/config/section.rb', line 103 def method_missing(name, *args) if @params.has_key?(name) @params[name] else ::Kernel.raise ::NoMethodError, "undefined method `#{name}' for #{self.inspect}" end end |
Class Method Details
.name ⇒ Object
25 26 27 |
# File 'lib/fluent/config/section.rb', line 25 def self.name 'Fluent::Config::Section' end |
Instance Method Details
#+(other) ⇒ Object
65 66 67 |
# File 'lib/fluent/config/section.rb', line 65 def +(other) Section.new(self.to_h.merge(other.to_h)) end |
#[](key) ⇒ Object
78 79 80 |
# File 'lib/fluent/config/section.rb', line 78 def [](key) @params[key.to_sym] end |
#[]=(key, value) ⇒ Object
82 83 84 |
# File 'lib/fluent/config/section.rb', line 82 def []=(key, value) @params[key.to_sym] = value end |
#class ⇒ Object
41 42 43 |
# File 'lib/fluent/config/section.rb', line 41 def class Section end |
#corresponding_config_element ⇒ Object
37 38 39 |
# File 'lib/fluent/config/section.rb', line 37 def corresponding_config_element @corresponding_config_element end |
#dup ⇒ Object
61 62 63 |
# File 'lib/fluent/config/section.rb', line 61 def dup Section.new(@params.dup, @corresponding_config_element.dup) end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/fluent/config/section.rb', line 49 def inspect "<Fluent::Config::Section #{@params.to_json}>" end |
#instance_of?(mod) ⇒ Boolean
69 70 71 |
# File 'lib/fluent/config/section.rb', line 69 def instance_of?(mod) @klass == mod.name end |
#kind_of?(mod) ⇒ Boolean Also known as: is_a?
73 74 75 |
# File 'lib/fluent/config/section.rb', line 73 def kind_of?(mod) @klass == mod.name || BasicObject == mod end |
#nil? ⇒ Boolean
53 54 55 |
# File 'lib/fluent/config/section.rb', line 53 def nil? false end |
#respond_to?(symbol, include_all = false) ⇒ Boolean
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fluent/config/section.rb', line 86 def respond_to?(symbol, include_all=false) case symbol when :inspect, :nil?, :to_h, :+, :instance_of?, :kind_of?, :[], :respond_to?, :respond_to_missing? true when :!, :!= , :==, :equal?, :instance_eval, :instance_exec true when :method_missing, :singleton_method_added, :singleton_method_removed, :singleton_method_undefined include_all else false end end |
#respond_to_missing?(symbol, include_private) ⇒ Boolean
99 100 101 |
# File 'lib/fluent/config/section.rb', line 99 def respond_to_missing?(symbol, include_private) @params.has_key?(symbol) end |
#to_h ⇒ Object
57 58 59 |
# File 'lib/fluent/config/section.rb', line 57 def to_h @params end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/fluent/config/section.rb', line 45 def to_s inspect end |