Class: Settable::SettingBlock
- Inherits:
-
Object
- Object
- Settable::SettingBlock
- Defined in:
- lib/settable.rb
Overview
Private: Wrapper around the setting’s value. Returns the wrapped value.
Instance Method Summary collapse
-
#call ⇒ Object
Public: Retrieve the value from this block, if we are using environment checkers then we will check the environment and override any default values.
-
#initialize(namespace, &block) ⇒ SettingBlock
constructor
Public: Create a setting block in the given namespace.
Constructor Details
#initialize(namespace, &block) ⇒ SettingBlock
Public: Create a setting block in the given namespace.
namespace - The namespace to operate in. block - The block to call when retrieving the setting.
Returns the setting value block.
122 123 124 125 126 |
# File 'lib/settable.rb', line 122 def initialize(namespace, &block) @block = lambda &block @namespace = namespace @environment = namespace.environment end |
Instance Method Details
#call ⇒ Object
Public: Retrieve the value from this block, if we are using environment
checkers then we will check the environment and override any
default values
Returns the value for the setting.
133 134 135 136 137 |
# File 'lib/settable.rb', line 133 def call @__env_return_value__ = nil # avoid using throw/catch default_return_value = instance_eval &@block @__env_return_value__ || default_return_value end |