class Hyperb::Client

client class

Constants

REGIONS

Attributes

access_key[RW]
region[RW]
secret_key[RW]

Public Class Methods

new(options = {}) { |self| ... } click to toggle source
# File lib/hyperb/client.rb, line 16
def initialize(options = {})
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
  validate_and_set_region
  yield(self) if block_given?
end

Public Instance Methods

blank?(val) click to toggle source
# File lib/hyperb/client.rb, line 51
def blank?(val)
  val.respond_to?(:empty?) ? val.empty? : !val
end
credentials() click to toggle source
# File lib/hyperb/client.rb, line 40
def credentials
  {
    secret_key: secret_key,
    access_key: access_key
  }
end
credentials?() click to toggle source
# File lib/hyperb/client.rb, line 47
def credentials?
  credentials.values.none? { |cred| blank?(cred) }
end
default_region() click to toggle source
# File lib/hyperb/client.rb, line 32
def default_region
  REGIONS.first
end
supported_region?(region) click to toggle source
# File lib/hyperb/client.rb, line 36
def supported_region?(region)
  REGIONS.include?(region.to_s)
end
validate_and_set_region() click to toggle source
# File lib/hyperb/client.rb, line 24
def validate_and_set_region
  if @region.nil?
    @region = default_region
  else
    raise Hyperb::Error::UnsupportedRegion, @region.to_s unless supported_region?(@region)
  end
end