summaryrefslogtreecommitdiff
path: root/app/models/service_level.rb
blob: d0bd9b3f59d5ddaedf34f79c577795d59618a96f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class ServiceLevel

  def initialize(attributes = {})
    @id = attributes[:id] || APP_CONFIG[:default_service_level]
  end

  def self.authenticated_select_options
    APP_CONFIG[:service_levels].map { |id,config_hash| [config_hash[:description], id] if config_hash[:name] != 'anonymous'}.compact
  end

  def id
    @id
  end

  def config_hash
    @config_hash || APP_CONFIG[:service_levels][@id].with_indifferent_access
  end

  delegate :to_json, to: :config_hash

  def provides?(service)
    services.include? service.to_s
  end

  def services
    config_hash[:services] || []
  end

  def cert_prefix
    config_hash[:cert_prefix]
  end
end