Class: AnalyticsOps::Configuration::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_ops/configuration/document.rb,
sig/analytics_ops.rbs

Overview

Immutable collection of validated named profiles.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version:, profiles:) ⇒ Document

Returns a new instance of Document.

Parameters:



11
12
13
14
15
# File 'lib/analytics_ops/configuration/document.rb', line 11

def initialize(version:, profiles:)
  @version = version
  @profiles = Canonical.immutable(profiles)
  freeze
end

Instance Attribute Details

#profilesHash[String, DesiredState] (readonly)

Returns the value of attribute profiles.

Returns:



9
10
11
# File 'lib/analytics_ops/configuration/document.rb', line 9

def profiles
  @profiles
end

#versionInteger (readonly)

Returns the value of attribute version.

Returns:

  • (Integer)


9
10
11
# File 'lib/analytics_ops/configuration/document.rb', line 9

def version
  @version
end

Instance Method Details

#profile(name) ⇒ DesiredState

Parameters:

  • name (String, Symbol)

Returns:



17
18
19
20
21
22
# File 'lib/analytics_ops/configuration/document.rb', line 17

def profile(name)
  profiles.fetch(name.to_s) do
    available = profiles.keys.sort.join(", ")
    raise ConfigurationError, "Unknown profile #{name.inspect}; available profiles: #{available}"
  end
end