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
-
#pretty_print(q) ⇒ Object
Used by PP and Pry.
- #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
108 109 110 111 112 113 114 |
# File 'lib/fluent/config/section.rb', line 108 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
70 71 72 |
# File 'lib/fluent/config/section.rb', line 70 def +(other) Section.new(self.to_h.merge(other.to_h)) end |
#[](key) ⇒ Object
83 84 85 |
# File 'lib/fluent/config/section.rb', line 83 def [](key) @params[key.to_sym] end |
#[]=(key, value) ⇒ Object
87 88 89 |
# File 'lib/fluent/config/section.rb', line 87 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
66 67 68 |
# File 'lib/fluent/config/section.rb', line 66 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
74 75 76 |
# File 'lib/fluent/config/section.rb', line 74 def instance_of?(mod) @klass == mod.name end |
#kind_of?(mod) ⇒ Boolean Also known as: is_a?
78 79 80 |
# File 'lib/fluent/config/section.rb', line 78 def kind_of?(mod) @klass == mod.name || BasicObject == mod end |
#nil? ⇒ Boolean
58 59 60 |
# File 'lib/fluent/config/section.rb', line 58 def nil? false end |
#pretty_print(q) ⇒ Object
Used by PP and Pry
54 55 56 |
# File 'lib/fluent/config/section.rb', line 54 def pretty_print(q) q.text(inspect) end |
#respond_to?(symbol, include_all = false) ⇒ Boolean
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/fluent/config/section.rb', line 91 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
104 105 106 |
# File 'lib/fluent/config/section.rb', line 104 def respond_to_missing?(symbol, include_private) @params.has_key?(symbol) end |
#to_h ⇒ Object
62 63 64 |
# File 'lib/fluent/config/section.rb', line 62 def to_h @params end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/fluent/config/section.rb', line 45 def to_s inspect end |