Class: Fett::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/fett/app.rb

Instance Method Summary collapse

Instance Method Details

#transaction(options, &block) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fett/app.rb', line 59

def transaction(options, &block)
  begin
    status options[:success]

    response = yield

    return if options[:success] == 204

    json response
  rescue RuntimeError => error
    status 400
    json error: error.message
  end
end