Class: AnalyticsOps::Configuration::Writer::Result

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

Overview

Immutable description of a configuration write or no-op.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, created:, updated: false) ⇒ Result

Returns a new instance of Result.

Parameters:

  • path: (String)
  • created: (Boolean)
  • updated: (Boolean) (defaults to: false)


16
17
18
19
20
21
22
23
24
25
# File 'lib/analytics_ops/configuration/writer.rb', line 16

def initialize(path:, created:, updated: false)
  unless [true, false].include?(created) && [true, false].include?(updated) && !(created && updated)
    raise ArgumentError, "created and updated must be distinct booleans"
  end

  @path = path.to_s.dup.freeze
  @created = created
  @updated = updated
  freeze
end

Instance Attribute Details

#pathString (readonly)

Returns the value of attribute path.

Returns:

  • (String)


14
15
16
# File 'lib/analytics_ops/configuration/writer.rb', line 14

def path
  @path
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


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

def changed?
  created? || updated?
end

#created?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/analytics_ops/configuration/writer.rb', line 27

def created?
  @created
end

#to_hrecord

Returns:

  • (record)


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

def to_h
  { "path" => path, "created" => created?, "updated" => updated? }
end

#updated?Boolean

Returns:

  • (Boolean)


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

def updated?
  @updated
end