Class: Middleman::CoreExtensions::Data::Stores::InMemoryDataStore

Inherits:
BaseDataStore
  • Object
show all
Extended by:
Forwardable
Includes:
Contracts
Defined in:
middleman-core/lib/middleman-core/core_extensions/data/stores/in_memory.rb

Overview

Static data, passed in via config.rb

Constant Summary

Constants included from Contracts

Contracts::ImmutableSetOf, Contracts::ImmutableSortedSetOf, Contracts::OldResourceList, Contracts::PATH_MATCHER, Contracts::ResourceList, Contracts::VectorOf

Instance Method Summary collapse

Methods included from Contracts

#Contract

Methods inherited from BaseDataStore

#[], #key?, #keys, #to_h

Constructor Details

#initializeInMemoryDataStore



18
19
20
21
22
23
# File 'middleman-core/lib/middleman-core/core_extensions/data/stores/in_memory.rb', line 18

def initialize
  super()

  @sources = {}
  @keys_to_vertex = {}
end

Instance Method Details

#callbacks(name, callback) ⇒ Object



45
46
47
# File 'middleman-core/lib/middleman-core/core_extensions/data/stores/in_memory.rb', line 45

def callbacks(name, callback)
  store(name, callback.call)
end

#store(name, content) ⇒ Object



36
37
38
39
40
41
# File 'middleman-core/lib/middleman-core/core_extensions/data/stores/in_memory.rb', line 36

def store(name, content)
  @sources[name] = content

  @keys_to_vertex[name] = ::Hamster::Set.empty
  @keys_to_vertex[name] <<= ::Middleman::Dependencies::DataCollectionVertex.from_data(name, content)
end

#SymbolHash

Store static data hash



35
# File 'middleman-core/lib/middleman-core/core_extensions/data/stores/in_memory.rb', line 35

Contract Symbol, Or[Hash, Array] => Any

#verticesObject



26
27
28
# File 'middleman-core/lib/middleman-core/core_extensions/data/stores/in_memory.rb', line 26

def vertices
  Hamster::Set.new(@keys_to_vertex.values.flatten(1))
end