aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential_cloning.rb
blob: 8d765f9851db1a8322c770d2d4690471cddc52e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class ReferentialCloning < ActiveRecord::Base
  include AASM
  belongs_to :source_referential, class_name: 'Referential'
  belongs_to :target_referential, class_name: 'Referential'

  aasm column: :status do
    state :new, :initial => true
    state :pending
    state :successful
    state :failed

    event :run do
      transitions :from => [:new, :failed], :to => :pending
    end

    event :successful do
      transitions :from => [:pending, :failed], :to => :successful
    end

    event :failed do
      transitions :from => :pending, :to => :failed
    end
  end
end