mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
restructure, de-nest
This commit is contained in:
parent
4c70b0fc54
commit
ef0eb25715
8 changed files with 211 additions and 222 deletions
|
@ -1 +1,9 @@
|
|||
module AASM
|
||||
end
|
||||
|
||||
require 'ostruct'
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'aasm', 'supporting_classes')
|
||||
require File.join(File.dirname(__FILE__), 'aasm', 'state_machine')
|
||||
require File.join(File.dirname(__FILE__), 'aasm', 'persistence')
|
||||
require File.join(File.dirname(__FILE__), 'aasm', 'aasm')
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
require File.join(File.dirname(__FILE__), 'event')
|
||||
require File.join(File.dirname(__FILE__), 'state')
|
||||
require File.join(File.dirname(__FILE__), 'state_machine')
|
||||
require File.join(File.dirname(__FILE__), 'persistence')
|
||||
|
||||
module AASM
|
||||
class InvalidTransition < RuntimeError
|
||||
end
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
require File.join(File.dirname(__FILE__), 'state_transition')
|
||||
|
||||
module AASM
|
||||
module SupportingClasses
|
||||
class Event
|
||||
class AASM::SupportingClasses::Event
|
||||
attr_reader :name, :success, :options
|
||||
|
||||
def initialize(name, options = {}, &block)
|
||||
|
@ -90,9 +86,7 @@ module AASM
|
|||
|
||||
def transitions(trans_opts)
|
||||
Array(trans_opts[:from]).each do |s|
|
||||
@transitions << SupportingClasses::StateTransition.new(trans_opts.merge({:from => s.to_sym}))
|
||||
end
|
||||
end
|
||||
@transitions << AASM::SupportingClasses::StateTransition.new(trans_opts.merge({:from => s.to_sym}))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module AASM
|
||||
module Persistence
|
||||
module AASM::Persistence
|
||||
|
||||
# Checks to see this class or any of it's superclasses inherit from
|
||||
# ActiveRecord::Base and if so includes ActiveRecordPersistence
|
||||
|
@ -13,4 +12,3 @@ module AASM
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
module AASM
|
||||
module SupportingClasses
|
||||
class State
|
||||
class AASM::SupportingClasses::State
|
||||
attr_reader :name, :options
|
||||
|
||||
def initialize(name, options={})
|
||||
|
@ -51,5 +49,3 @@ module AASM
|
|||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
require 'ostruct'
|
||||
|
||||
module AASM
|
||||
class StateMachine
|
||||
class AASM::StateMachine
|
||||
def self.[](*args)
|
||||
(@machines ||= {})[args]
|
||||
end
|
||||
|
@ -33,4 +30,3 @@ module AASM
|
|||
@states << AASM::SupportingClasses::State.new(name, options) unless @states.include?(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
module AASM
|
||||
module SupportingClasses
|
||||
class StateTransition
|
||||
class AASM::SupportingClasses::StateTransition
|
||||
attr_reader :from, :to, :opts
|
||||
alias_method :options, :opts
|
||||
|
||||
|
@ -46,5 +44,3 @@ module AASM
|
|||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
lib/aasm/supporting_classes.rb
Normal file
6
lib/aasm/supporting_classes.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
module AASM::SupportingClasses
|
||||
end
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'state_transition')
|
||||
require File.join(File.dirname(__FILE__), 'event')
|
||||
require File.join(File.dirname(__FILE__), 'state')
|
Loading…
Add table
Add a link
Reference in a new issue