Module: Hoss::Config::Options::InstanceMethods Private
- Defined in:
- lib/hoss/config/options.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #[](key) ⇒ Object (also: #get) private
- #load_schema ⇒ Object private
- #method_missing(name, *value) ⇒ Object private
- #set(key, value) ⇒ Object private
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/hoss/config/options.rb', line 116 def method_missing(name, *value) name_str = name.to_s if name_str.end_with?('=') key = name_str[0...-1].to_sym set(key, value.first) elsif name_str.end_with?('?') key = name_str[0...-1].to_sym .key?(key) ? [key].value : super elsif .key?(name) .fetch(name).value else super end end |
Instance Method Details
#[](key) ⇒ Object Also known as: get
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 |
# File 'lib/hoss/config/options.rb', line 135 def [](key) [key] end |
#load_schema ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
110 111 112 113 114 |
# File 'lib/hoss/config/options.rb', line 110 def load_schema Hash[self.class.schema.map do |key, args| [key, Option.new(key, **args)] end] end |
#set(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 141 142 143 144 145 |
# File 'lib/hoss/config/options.rb', line 140 def set(key, value) .fetch(key.to_sym).set(value) rescue KeyError warn format("Unknown option '%s'", key) nil end |