Class: Onceler::Configuration
- Inherits:
-
Object
- Object
- Onceler::Configuration
- Defined in:
- lib/onceler/configuration.rb
Instance Method Summary collapse
- #after(scope, &block) ⇒ Object
- #before(scope, &block) ⇒ Object
- #hooks ⇒ Object
- #run_hooks(timing, scope, context) ⇒ Object
Instance Method Details
#after(scope, &block) ⇒ Object
15 16 17 |
# File 'lib/onceler/configuration.rb', line 15 def after(scope, &block) hooks[:after][scope] << block end |
#before(scope, &block) ⇒ Object
11 12 13 |
# File 'lib/onceler/configuration.rb', line 11 def before(scope, &block) hooks[:before][scope] << block end |
#hooks ⇒ Object
19 20 21 22 23 24 |
# File 'lib/onceler/configuration.rb', line 19 def hooks @hooks ||= { before: {record: [], reset: []}, after: {record: [], reset: []} } end |
#run_hooks(timing, scope, context) ⇒ Object
26 27 28 29 30 |
# File 'lib/onceler/configuration.rb', line 26 def run_hooks(timing, scope, context) hooks[timing][scope].each do |hook| context ? context.instance_eval(&hook) : hook.call end end |