Class: Generic::InsEval
- Inherits:
-
Object
- Object
- Generic::InsEval
- Defined in:
- lib/generic/generic.rb
Class Method Summary collapse
- .apply(scope, &handler) ⇒ Object
- .hand(scope_class, handler, before_actions, after_actions) ⇒ Object
- .instance(scope, &block) ⇒ Object
Class Method Details
.apply(scope, &handler) ⇒ Object
22 23 24 |
# File 'lib/generic/generic.rb', line 22 def self.apply(scope, &handler) scope.apply &handler end |
.hand(scope_class, handler, before_actions, after_actions) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generic/generic.rb', line 26 def self.hand(scope_class, handler, before_actions, after_actions) Proc.new do |env| scope = scope_class.new(env) response = catch (:halt) do before_actions.each do |action| Generic::InsEval.instance(scope, &action) end Generic::InsEval.apply(scope, &handler) end catch (:halt) do after_actions.each do |action| Generic::InsEval.apply(scope, &action) end end response.finish end end |
.instance(scope, &block) ⇒ Object
18 19 20 |
# File 'lib/generic/generic.rb', line 18 def self.instance(scope, &block) scope.instance_eval &block end |