Module: Appydays::Configurable::ClassMethods
- Defined in:
- lib/appydays/configurable.rb
Instance Method Summary collapse
- #configurable(key, &block) ⇒ Object
-
#reset_configuration(overrides = {}) ⇒ Object
Restore all settings back to the values they were at config time (undoes any manual attribute writes), and runs after_configured hooks.
-
#run_after_configured_hooks ⇒ Object
Explicitly run after configuration hooks.
Instance Method Details
#configurable(key, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/appydays/configurable.rb', line 40 def configurable(key, &block) raise LocalJumpError unless block installer = Installer.new(self, key) self.define_singleton_method(:_configuration_installer) { installer } installer.instance_eval(&block) installer._run_after_configured end |
#reset_configuration(overrides = {}) ⇒ Object
Restore all settings back to the values they were at config time (undoes any manual attribute writes), and runs after_configured hooks.
overrides can be passed, to apply new manual overrides before running after_configured hooks. This is very useful when testing classes that have an after_configured hook.
58 59 60 |
# File 'lib/appydays/configurable.rb', line 58 def reset_configuration(overrides={}) self._configuration_installer._reset(overrides) end |
#run_after_configured_hooks ⇒ Object
Explicitly run after configuration hooks. This may need to be run explicitly after reset, if the ‘after_configured` hook involves side effects. Side effects are gnarly so we don’t make assumptions.
67 68 69 |
# File 'lib/appydays/configurable.rb', line 67 def run_after_configured_hooks self._configuration_installer._run_after_configured end |