Class: NilSection
Overview
A NilSection is returned for all missing/empty values in the config file. This allows for terse code when accessing values that have not been configured by the user.
Consider code like this:
config.server.listen.tap do |listen|
open_socket(listen.host, listen.port)
end
Given that your server component is optional and does not appear in the configuration file at all, config.server.listen
will return a NilSection that does not call the block given to tap _at all_.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
True.
-
#nil? ⇒ Boolean
True.
-
#present? ⇒ Boolean
False.
-
#tap ⇒ Object
Nil.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
171 172 173 |
# File 'lib/madvertise/ext/config.rb', line 171 def method_missing(*args, &block) self end |
Instance Method Details
#empty? ⇒ Boolean
Returns true.
156 157 158 |
# File 'lib/madvertise/ext/config.rb', line 156 def empty? true end |
#nil? ⇒ Boolean
Returns true.
151 152 153 |
# File 'lib/madvertise/ext/config.rb', line 151 def nil? true end |
#present? ⇒ Boolean
Returns false.
161 162 163 |
# File 'lib/madvertise/ext/config.rb', line 161 def present? false end |
#tap ⇒ Object
Returns nil.
166 167 168 |
# File 'lib/madvertise/ext/config.rb', line 166 def tap nil end |