Sha256: 064fabdad2b618c8f1d23918bde986be84f19c966a8e60ffcd3fae1f9a8e1af3

Contents?: true

Size: 768 Bytes

Versions: 6

Compression:

Stored size: 768 Bytes

Contents

# -*- coding: utf-8 -*-
require 'statemachine'

module Dcmgr::Stm
  class SnapshotContext < OpenStruct

    attr_reader :stm

    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

    def state
      @stm.state
    end

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
wakame-vdc-agents-11.06.0 lib/dcmgr/stm/snapshot_context.rb
wakame-vdc-dcmgr-11.06.0 lib/dcmgr/stm/snapshot_context.rb
wakame-vdc-dcmgr-10.12.0 lib/dcmgr/stm/snapshot_context.rb
wakame-vdc-agents-10.12.0 lib/dcmgr/stm/snapshot_context.rb
wakame-vdc-dcmgr-10.11.0 lib/dcmgr/stm/snapshot_context.rb
wakame-vdc-agents-10.11.0 lib/dcmgr/stm/snapshot_context.rb