Class: ConcurrentPipeline::Stores::Yaml::History::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/concurrent_pipeline/stores/yaml/history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, changesets:, registry:) ⇒ Version

Returns a new instance of Version.



14
15
16
17
18
# File 'lib/concurrent_pipeline/stores/yaml/history.rb', line 14

def initialize(index:, changesets:, registry:)
  @index = index
  @changesets = changesets[0..index]
  @registry = registry
end

Instance Attribute Details

#changesetsObject (readonly)

Returns the value of attribute changesets.



13
14
15
# File 'lib/concurrent_pipeline/stores/yaml/history.rb', line 13

def changesets
  @changesets
end

#indexObject (readonly)

Returns the value of attribute index.



13
14
15
# File 'lib/concurrent_pipeline/stores/yaml/history.rb', line 13

def index
  @index
end

#registryObject (readonly)

Returns the value of attribute registry.



13
14
15
# File 'lib/concurrent_pipeline/stores/yaml/history.rb', line 13

def registry
  @registry
end

Instance Method Details

#diffObject



29
30
31
# File 'lib/concurrent_pipeline/stores/yaml/history.rb', line 29

def diff
  changesets.last.as_json
end

#storeObject



20
21
22
23
24
25
26
27
# File 'lib/concurrent_pipeline/stores/yaml/history.rb', line 20

def store
  @store ||= (
    Db
      .new(data: {}, registry: registry)
      .tap { _1.apply(changesets) }
      .reader
  )
end