Class: Dcmgr::Stm::SnapshotContext

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/dcmgr/stm/snapshot_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(snapshot_id = nil) ⇒ SnapshotContext

Returns a new instance of SnapshotContext.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dcmgr/stm/snapshot_context.rb', line 9

def initialize(snapshot_id=nil)
  super({:snapshot_id=>snapshot_id})
  @stm = Statemachine.build {
    trans :registering, :on_create, :creating
    trans :creating, :on_create, :available
    trans :available, :on_delete, :deleting
    trans :deleting, :on_delete, :deleted

    trans :registering, :on_fail, :failed
    trans :creating, :on_fail, :failed
    trans :available, :on_fail, :failed
    trans :deleting, :on_fail, :failed
  }
  @stm.context = self
end

Instance Attribute Details

#stmObject (readonly)

Returns the value of attribute stm.



7
8
9
# File 'lib/dcmgr/stm/snapshot_context.rb', line 7

def stm
  @stm
end

Instance Method Details

#stateObject



25
26
27
# File 'lib/dcmgr/stm/snapshot_context.rb', line 25

def state
  @stm.state
end

#to_hashObject



29
30
31
# File 'lib/dcmgr/stm/snapshot_context.rb', line 29

def to_hash
  @table.dup.merge({:state=>@stm.state})
end