Class: Provider

Inherits:
Base
  • Object
show all
Includes:
DeterministicHash
Defined in:
app/models/provider.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DeterministicHash

#deterministic_hash

Methods inherited from Base

ma_accessor, ma_reader, ma_writer, #serialize_more_attributes

Class Method Details

.update_providersObject


23
24
25
# File 'app/models/provider.rb', line 23

def self.update_providers
  UpdateProvidersJob.perform_later
end

Instance Method Details

#availabilityObject

Return availability of provider if there is none, assume 0.95


7
8
9
10
11
12
13
# File 'app/models/provider.rb', line 7

def availability
  if more_attributes['sla'] && more_attributes['sla']['availability']
    BigDecimal(more_attributes['sla']['availability'].to_s)
  else
    0.95
  end
end

#region_code(region_name) ⇒ Object

Assuming that a region is identified by the composite key: 1) provider_name 2) region_name


18
19
20
21
# File 'app/models/provider.rb', line 18

def region_code(region_name)
  region_string = self.name.to_s + region_name.to_s
  deterministic_hash(region_string)
end