Module: Virtuatable::Helpers::Gateways

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

Overview

These helpers holds getters and checkers about API gateways.

Author:

Instance Method Summary collapse

Instance Method Details

#gatewayArkaan::Monitoring::Gateway

Gets the gateway associated to the gatexway token in parameters.

Returns:

  • (Arkaan::Monitoring::Gateway)

    the gateway requesting the service



10
11
12
# File 'lib/virtuatable/helpers/gateways.rb', line 10

def gateway
  Arkaan::Monitoring::Gateway.where(token: params['token']).first
end

#gateway!Object

Checks the gateway requesting the service and raises an error if necessary.



15
16
17
18
19
20
# File 'lib/virtuatable/helpers/gateways.rb', line 15

def gateway!
  check_presence 'token'
  api_not_found 'token.unknown' if gateway.nil?

  gateway
end