diff --git a/lib/aasm.rb b/lib/aasm.rb index 9a93b02..b4dd7d9 100644 --- a/lib/aasm.rb +++ b/lib/aasm.rb @@ -3,6 +3,7 @@ require 'ostruct' %w( version errors + configuration base instance_base transition diff --git a/lib/aasm/base.rb b/lib/aasm/base.rb index 867393c..b223fbd 100644 --- a/lib/aasm/base.rb +++ b/lib/aasm/base.rb @@ -95,7 +95,6 @@ module AASM private def configure(key, default_value) - @state_machine.config.send(:new_ostruct_member, key) if @options.key?(key) @state_machine.config.send("#{key}=", @options[key]) elsif @state_machine.config.send(key).nil? diff --git a/lib/aasm/configuration.rb b/lib/aasm/configuration.rb new file mode 100644 index 0000000..2ec2218 --- /dev/null +++ b/lib/aasm/configuration.rb @@ -0,0 +1,21 @@ +module AASM + class Configuration + # for all persistence layers: which database column to use? + attr_accessor :column + + # let's cry if the transition is invalid + attr_accessor :whiny_transitions + + # for all persistence layers: create named scopes for each state + attr_accessor :create_scopes + + # for ActiveRecord: don't store any new state if the model is invalid + attr_accessor :skip_validation_on_save + + # for ActiveRecord: use requires_new for nested transactions? + attr_accessor :requires_new_transaction + + # forbid direct assignment in aasm_state column (in ActiveRecord) + attr_accessor :no_direct_assignment + end +end \ No newline at end of file diff --git a/lib/aasm/state_machine.rb b/lib/aasm/state_machine.rb index 2e9ed07..33ba0d2 100644 --- a/lib/aasm/state_machine.rb +++ b/lib/aasm/state_machine.rb @@ -19,7 +19,7 @@ module AASM @initial_state = nil @states = [] @events = {} - @config = OpenStruct.new + @config = AASM::Configuration.new end # called internally by Ruby 1.9 after clone()