Class: Dcmgr::Stm::SnapshotContext
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Dcmgr::Stm::SnapshotContext
- Defined in:
- lib/dcmgr/stm/snapshot_context.rb
Instance Attribute Summary collapse
-
#stm ⇒ Object
readonly
Returns the value of attribute stm.
Instance Method Summary collapse
-
#initialize(snapshot_id = nil) ⇒ SnapshotContext
constructor
A new instance of SnapshotContext.
- #state ⇒ Object
- #to_hash ⇒ Object
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
#stm ⇒ Object (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
#state ⇒ Object
25 26 27 |
# File 'lib/dcmgr/stm/snapshot_context.rb', line 25 def state @stm.state end |
#to_hash ⇒ Object
29 30 31 |
# File 'lib/dcmgr/stm/snapshot_context.rb', line 29 def to_hash @table.dup.merge({:state=>@stm.state}) end |