class ActiveCommand::CommandRunner
Public Class Methods
new(app)
click to toggle source
# File lib/active_command/middleware/command_runner.rb, line 6 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/active_command/middleware/command_runner.rb, line 10 def call(env) at = env.fetch(:at, :later) cmd = env.fetch(:command, nil) result = CommandResult.new(cmd).tap do |cr| begin raise MissingCommandError if cr.command.nil? cr.command.run if at == :later cr.command.perform_now if at == :now rescue StandardError => e cr.error = e end end env[:command_result] = result @app.call(env) if @app end