class Generic::InsEval

Public Class Methods

apply(scope, &handler) click to toggle source
# File lib/generic/generic.rb, line 22
def self.apply(scope, &handler)
  scope.apply &handler
end
hand(scope_class, handler, before_actions, after_actions) click to toggle source
# 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) click to toggle source
# File lib/generic/generic.rb, line 18
def self.instance(scope, &block)
  scope.instance_eval &block
end