Module: Core::Helpers::Declarators

Included in:
Controllers::Base
Defined in:
lib/core/helpers/declarators.rb

Overview

This helpers module is a bit larger than the others as it provides methods to declare routes whithin a service, performing needed checks and filters.

Author:

Instance Method Summary collapse

Instance Method Details

#api_route(verb, path, premium: false, scopes: ['data::usage'], &block) ⇒ Object

Main method to declare new routes, persisting them in the database and declaring it in the Sinatra application with the needed before checks.



16
17
18
19
20
21
22
23
24
# File 'lib/core/helpers/declarators.rb', line 16

def api_route(verb, path, premium: false, scopes: ['data::usage'], &block)
  send(verb, path) do
    scope_objects = fetch_scopes(scopes)
    appli = application(premium: premium)
    check_app_scopes(appli, scope_objects)
    check_token_scopes(token, scope_objects)
    instance_eval(&block)
  end
end