Class: StateSync::Store
- Inherits:
-
Object
- Object
- StateSync::Store
- 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
-
#[](key) ⇒ Object
Shorthand key access (delegates to #data).
-
#data ⇒ Object
Returns data in the format set by Configuration#data_format.
-
#initialize(path) ⇒ Store
constructor
A new instance of Store.
-
#reload! ⇒ Object
Force an immediate re-fetch from the configured provider.
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 |
#data ⇒ Object
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 |