Class: AnalyticsOps::Setup::Result

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

Overview

Immutable setup outcome returned to the CLI and Ruby callers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path:, profile:, property:, created:, updated: false, warnings: []) ⇒ Result

Returns a new instance of Result.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/analytics_ops/setup.rb', line 14

def initialize(config_path:, profile:, property:, created:, updated: false, warnings: [])
  unless property.is_a?(Resources::Property)
    raise ArgumentError, "property must be an AnalyticsOps::Resources::Property"
  end
  unless [true, false].include?(created) && [true, false].include?(updated) && !(created && updated)
    raise ArgumentError, "created and updated must be distinct booleans"
  end

  @config_path = config_path.to_s.dup.freeze
  @profile = profile.to_s.dup.freeze
  @property = property
  @created = created
  @updated = updated
  @warnings = normalized_warnings(warnings)
  freeze
end

Instance Attribute Details

#config_pathString (readonly)

Returns the value of attribute config_path.

Returns:

  • (String)


12
13
14
# File 'lib/analytics_ops/setup.rb', line 12

def config_path
  @config_path
end

#profileString (readonly)

Returns the value of attribute profile.

Returns:

  • (String)


12
13
14
# File 'lib/analytics_ops/setup.rb', line 12

def profile
  @profile
end

#propertyResources::Property (readonly)

Returns the value of attribute property.

Returns:



12
13
14
# File 'lib/analytics_ops/setup.rb', line 12

def property
  @property
end

#warningsArray[String] (readonly)

Returns the value of attribute warnings.

Returns:

  • (Array[String])


12
13
14
# File 'lib/analytics_ops/setup.rb', line 12

def warnings
  @warnings
end

Instance Method Details

#created?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/analytics_ops/setup.rb', line 31

def created?
  @created
end

#statusString

Returns:

  • (String)


39
40
41
# File 'lib/analytics_ops/setup.rb', line 39

def status
  created? || updated? ? "configured" : "already_configured"
end

#to_hrecord

Returns:

  • (record)


43
44
45
46
47
48
49
50
51
52
# File 'lib/analytics_ops/setup.rb', line 43

def to_h
  {
    "status" => status,
    "config" => config_path,
    "profile" => profile,
    "updated" => updated?,
    "warnings" => warnings,
    "property" => property.to_h
  }
end

#updated?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/analytics_ops/setup.rb', line 35

def updated?
  @updated
end