module Grape::DSL::Callbacks::ClassMethods
Public Instance Methods
after(&block)
click to toggle source
Execute the given block after the endpoint code has run.
# File lib/grape/dsl/callbacks.rb, line 45 def after(&block) namespace_stackable(:afters, block) end
after_validation(&block)
click to toggle source
Execute the given block after validations and coercions, but before any endpoint code.
# File lib/grape/dsl/callbacks.rb, line 40 def after_validation(&block) namespace_stackable(:after_validations, block) end
before(&block)
click to toggle source
Execute the given block before validation, coercion, or any endpoint code is executed.
# File lib/grape/dsl/callbacks.rb, line 28 def before(&block) namespace_stackable(:befores, block) end
before_validation(&block)
click to toggle source
Execute the given block after `before`, but prior to validation or coercion.
# File lib/grape/dsl/callbacks.rb, line 34 def before_validation(&block) namespace_stackable(:before_validations, block) end
finally(&block)
click to toggle source
Allows you to specify a something that will always be executed after a call API
call. Unlike the `after` block, this code will run even on unsuccesful requests. @example
class ExampleAPI < Grape::API before do ApiLogger.start end finally do ApiLogger.close end end
This will make sure that the ApiLogger is opened and closed around every request @param ensured_block [Proc] The block to be executed after every api_call
# File lib/grape/dsl/callbacks.rb, line 65 def finally(&block) namespace_stackable(:finallies, block) end