| Module | Grape::DSL::Helpers::ClassMethods |
| In: |
lib/grape/dsl/helpers.rb
|
Add helper methods that will be accessible from any endpoint within this namespace (and child namespaces).
When called without a block, all known helpers within this scope are included.
@param [Array] new_modules optional array of modules to include @param [Block] block optional block of methods to include
@example Define some helpers.
class ExampleAPI < Grape::API
helpers do
def current_user
User.find_by_id(params[:token])
end
end
end
@example Include many modules
class ExampleAPI < Grape::API
helpers Authentication, Mailer, OtherModule
end