Module: Virtuatable::Helpers::Applications

Included in:
Controllers::Base
Defined in:
lib/virtuatable/helpers/applications.rb

Overview

Helpers to get and check OAuth applications connecting the the application.

Author:

Instance Method Summary collapse

Instance Method Details

#application(premium: false) ⇒ Object

Looks for the application sending the API’s request, and raises error if not found.

Parameters:

  • the (Arkaan::OAuth::Application)

    application requesting the service.



10
11
12
13
14
15
16
17
18
19
# File 'lib/virtuatable/helpers/applications.rb', line 10

def application(premium: false)
  return @application unless @application.nil?

  check_presence 'app_key'
  @application = application_model.find_by(app_key: params['app_key'])
  api_not_found 'app_key.unknown' if @application.nil?
  api_forbidden 'app_key.forbidden' if premium && !@application.premium

  @application
end

#application_modelObject



21
22
23
# File 'lib/virtuatable/helpers/applications.rb', line 21

def application_model
  Arkaan::OAuth::Application
end