Class: StateSync::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/state_sync/store.rb

Overview

Holds the parsed contents of a single YAML file fetched from GitHub or GitLab. On initialization it fetches the file immediately.

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Store

Returns a new instance of Store.



7
8
9
10
11
12
# File 'lib/state_sync/store.rb', line 7

def initialize(path)
  @path    = path
  @fetcher = fetcher_for(StateSync.configuration)

  fetch_and_cache
end

Instance Method Details

#[](key) ⇒ Object

Shorthand key access (delegates to #data).



22
23
24
# File 'lib/state_sync/store.rb', line 22

def [](key)
  data[key]
end

#dataObject

Returns data in the format set by Configuration#data_format. :struct (default) — dot-access via OpenStruct :hash — raw Ruby Hash / Array / scalar



17
18
19
# File 'lib/state_sync/store.rb', line 17

def data
  @data
end

#reload!Object

Force an immediate re-fetch from the configured provider.



27
28
29
30
# File 'lib/state_sync/store.rb', line 27

def reload!
  fetch_and_cache
  self
end