Class: AnalyticsOps::Configuration::Writer::Result
- Inherits:
-
Object
- Object
- AnalyticsOps::Configuration::Writer::Result
- 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
-
#path ⇒ String
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #created? ⇒ Boolean
-
#initialize(path:, created:, updated: false) ⇒ Result
constructor
A new instance of Result.
- #to_h ⇒ record
- #updated? ⇒ Boolean
Constructor Details
#initialize(path:, created:, updated: false) ⇒ Result
Returns a new instance of Result.
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
#path ⇒ String (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/analytics_ops/configuration/writer.rb', line 14 def path @path end |
Instance Method Details
#changed? ⇒ Boolean
35 36 37 |
# File 'lib/analytics_ops/configuration/writer.rb', line 35 def changed? created? || updated? end |
#created? ⇒ Boolean
27 28 29 |
# File 'lib/analytics_ops/configuration/writer.rb', line 27 def created? @created end |
#to_h ⇒ 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
31 32 33 |
# File 'lib/analytics_ops/configuration/writer.rb', line 31 def updated? @updated end |