module Sequent::Web::Sinatra::SimpleCommandServiceHelpers

Public Instance Methods

execute_command(command) { || ... } click to toggle source

execute a single command. Since it is default for most cases a CommandNotValid exception is handled in this method.

Example usage:

post '/foo' do
  @command = FooCommand.from_params(params)
  execute_command(@command, :erb_name)
end
# File lib/sequent-sinatra/simple_command_service_helpers.rb, line 14
def execute_command(command)
  @command_service.execute_commands(command)
  yield if block_given?
rescue Sequent::Core::CommandNotValid => e
  yield e.errors_with_command_prefix if block_given?
end