mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00

* Add aasm features of ActiveRecord to Sequel! :) * All specs pass for sequel, activerecord, and mongoid. * Refactor Sequel models to be namespaced under “Sequel”. We should do something similar for ActiveRecord in the specs to avoid collisions. Addresses #474 (cherry picked from commit df97ce754f47864abbcb837227da5c4d0ff77289)
25 lines
601 B
Ruby
25 lines
601 B
Ruby
db = Sequel::DATABASES.first || Sequel.connect(SEQUEL_DB)
|
|
|
|
# if you want to see the statements while running the spec enable the following line
|
|
# db.loggers << Logger.new($stderr)
|
|
db.create_table(:multiples) do
|
|
primary_key :id
|
|
String :status
|
|
end
|
|
module Sequel
|
|
class Multiple < Sequel::Model(:multiples)
|
|
include AASM
|
|
|
|
attr_accessor :default
|
|
|
|
aasm :left, :column => :status
|
|
aasm :left do
|
|
state :alpha, :initial => true
|
|
state :beta
|
|
state :gamma
|
|
event :release do
|
|
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
|
end
|
|
end
|
|
end
|
|
end
|