Class: Dopv::StateStore
- Inherits:
-
Object
show all
- Defined in:
- lib/dopv/state_store.rb
Instance Method Summary
collapse
Constructor Details
#initialize(plan_name, plan_store) ⇒ StateStore
Returns a new instance of StateStore.
7
8
9
10
11
|
# File 'lib/dopv/state_store.rb', line 7
def initialize(plan_name, plan_store)
@plan_store = plan_store
@plan_name = plan_name
@state_store = @plan_store.state_store(plan_name, 'dopv')
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
42
43
44
|
# File 'lib/dopv/state_store.rb', line 42
def method_missing(m, *args, &block)
@state_store.send(m, *args, &block)
end
|
Instance Method Details
#export ⇒ Object
30
31
32
33
34
|
# File 'lib/dopv/state_store.rb', line 30
def export
@state_store.transaction(true) do
@state_store[:data_volumes] || {}
end
end
|
#import(data_volumes) ⇒ Object
36
37
38
39
40
|
# File 'lib/dopv/state_store.rb', line 36
def import(data_volumes)
@state_store.transaction do
@state_store[:data_volumes] = data_volumes
end
end
|
#update(options = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/dopv/state_store.rb', line 13
def update(options = {})
if options[:clear]
clear(options)
elsif options[:ignore]
ignore(options)
else
update_state(options)
end
rescue DopCommon::UnknownVersionError => e
Dopv.log.warn("The state had an unknown plan version #{e.message}")
Dopv.log.warn("Bumping state to most recent version")
ignore(options)
rescue => e
Dopv.log.error("An error occured during update: #{e.message}")
Dopv.log.error("Please update with the 'clear' or 'ignore' option")
end
|