Class: Virtuaservices::Factories::Gateways

Inherits:
Object
  • Object
show all
Defined in:
lib/virtuaservices/factories/gateways.rb

Overview

This class provides methods to create decorated services.

Author:

Class Method Summary collapse

Class Method Details

.random(action) ⇒ Virtuaservices::Decorators::Gateway, NilClass

Searches for a gateway via its key and returns it decorated.

Parameters:

  • key (String)

    the key of the server you want to find.

Returns:



10
11
12
13
14
15
16
# File 'lib/virtuaservices/factories/gateways.rb', line 10

def self.random(action)
  gateway = Virtuaservices::Monitoring::Gateway.where(active: true, running: true).first
  if gateway.nil?
    raise Virtuaservices::Factories::Errors::GatewayNotFound.new(action: action)
  end
  return Virtuaservices::Decorators::Gateway.new(action, gateway)
end