micro-max-box 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/aasm-6.0.0/CHANGELOG.md +497 -0
  3. data/aasm-6.0.0/LICENSE +20 -0
  4. data/aasm-6.0.0/README.md +1534 -0
  5. data/aasm-6.0.0/lib/aasm/aasm.rb +208 -0
  6. data/aasm-6.0.0/lib/aasm/base.rb +300 -0
  7. data/aasm-6.0.0/lib/aasm/configuration.rb +48 -0
  8. data/aasm-6.0.0/lib/aasm/core/event.rb +178 -0
  9. data/aasm-6.0.0/lib/aasm/core/invoker.rb +129 -0
  10. data/aasm-6.0.0/lib/aasm/core/invokers/base_invoker.rb +85 -0
  11. data/aasm-6.0.0/lib/aasm/core/invokers/class_invoker.rb +75 -0
  12. data/aasm-6.0.0/lib/aasm/core/invokers/literal_invoker.rb +90 -0
  13. data/aasm-6.0.0/lib/aasm/core/invokers/proc_invoker.rb +94 -0
  14. data/aasm-6.0.0/lib/aasm/core/state.rb +91 -0
  15. data/aasm-6.0.0/lib/aasm/core/transition.rb +83 -0
  16. data/aasm-6.0.0/lib/aasm/dsl_helper.rb +32 -0
  17. data/aasm-6.0.0/lib/aasm/errors.rb +22 -0
  18. data/aasm-6.0.0/lib/aasm/instance_base.rb +153 -0
  19. data/aasm-6.0.0/lib/aasm/localizer.rb +64 -0
  20. data/aasm-6.0.0/lib/aasm/minitest/allow_event.rb +13 -0
  21. data/aasm-6.0.0/lib/aasm/minitest/allow_transition_to.rb +13 -0
  22. data/aasm-6.0.0/lib/aasm/minitest/have_state.rb +13 -0
  23. data/aasm-6.0.0/lib/aasm/minitest/transition_from.rb +21 -0
  24. data/aasm-6.0.0/lib/aasm/minitest.rb +5 -0
  25. data/aasm-6.0.0/lib/aasm/minitest_spec.rb +15 -0
  26. data/aasm-6.0.0/lib/aasm/persistence/active_record_persistence.rb +174 -0
  27. data/aasm-6.0.0/lib/aasm/persistence/base.rb +89 -0
  28. data/aasm-6.0.0/lib/aasm/persistence/core_data_query_persistence.rb +94 -0
  29. data/aasm-6.0.0/lib/aasm/persistence/dynamoid_persistence.rb +92 -0
  30. data/aasm-6.0.0/lib/aasm/persistence/mongoid_persistence.rb +126 -0
  31. data/aasm-6.0.0/lib/aasm/persistence/no_brainer_persistence.rb +105 -0
  32. data/aasm-6.0.0/lib/aasm/persistence/orm.rb +154 -0
  33. data/aasm-6.0.0/lib/aasm/persistence/plain_persistence.rb +26 -0
  34. data/aasm-6.0.0/lib/aasm/persistence/redis_persistence.rb +112 -0
  35. data/aasm-6.0.0/lib/aasm/persistence/sequel_persistence.rb +83 -0
  36. data/aasm-6.0.0/lib/aasm/persistence.rb +54 -0
  37. data/aasm-6.0.0/lib/aasm/rspec/allow_event.rb +26 -0
  38. data/aasm-6.0.0/lib/aasm/rspec/allow_transition_to.rb +26 -0
  39. data/aasm-6.0.0/lib/aasm/rspec/have_state.rb +22 -0
  40. data/aasm-6.0.0/lib/aasm/rspec/transition_from.rb +36 -0
  41. data/aasm-6.0.0/lib/aasm/rspec.rb +5 -0
  42. data/aasm-6.0.0/lib/aasm/state_machine.rb +53 -0
  43. data/aasm-6.0.0/lib/aasm/state_machine_store.rb +77 -0
  44. data/aasm-6.0.0/lib/aasm/version.rb +3 -0
  45. data/aasm-6.0.0/lib/aasm.rb +21 -0
  46. data/aasm-6.0.0/lib/generators/aasm/aasm_generator.rb +16 -0
  47. data/aasm-6.0.0/lib/generators/aasm/orm_helpers.rb +41 -0
  48. data/aasm-6.0.0/lib/generators/active_record/aasm_generator.rb +40 -0
  49. data/aasm-6.0.0/lib/generators/active_record/templates/migration.rb +8 -0
  50. data/aasm-6.0.0/lib/generators/active_record/templates/migration_existing.rb +5 -0
  51. data/aasm-6.0.0/lib/generators/mongoid/aasm_generator.rb +28 -0
  52. data/aasm-6.0.0/lib/generators/nobrainer/aasm_generator.rb +28 -0
  53. data/aasm-6.0.0/lib/motion-aasm.rb +37 -0
  54. data/micro-max-box.gemspec +12 -0
  55. metadata +94 -0
@@ -0,0 +1,208 @@
1
+ module AASM
2
+ # this is used internally as an argument default value to represent no value
3
+ NO_VALUE = :_aasm_no_value
4
+
5
+ # provide a state machine for the including class
6
+ # make sure to load class methods as well
7
+ # initialize persistence for the state machine
8
+ def self.included(base) #:nodoc:
9
+ base.extend AASM::ClassMethods
10
+
11
+ # do not overwrite existing state machines, which could have been created by
12
+ # inheritance, see class method inherited
13
+ AASM::StateMachineStore.register(base)
14
+
15
+ AASM::Persistence.load_persistence(base)
16
+ super
17
+ end
18
+
19
+ module ClassMethods
20
+ # make sure inheritance (aka subclassing) works with AASM
21
+ def inherited(base)
22
+ AASM::StateMachineStore.register(base, self)
23
+
24
+ super
25
+ end
26
+
27
+ # this is the entry point for all state and event definitions
28
+ def aasm(*args, &block)
29
+ if args[0].is_a?(Symbol) || args[0].is_a?(String)
30
+ # using custom name
31
+ state_machine_name = args[0].to_sym
32
+ options = args[1] || {}
33
+ else
34
+ # using the default state_machine_name
35
+ state_machine_name = :default
36
+ options = args[0] || {}
37
+ end
38
+
39
+ AASM::StateMachineStore.fetch(self, true).register(state_machine_name, AASM::StateMachine.new(state_machine_name))
40
+
41
+ # use a default despite the DSL configuration default.
42
+ # this is because configuration hasn't been setup for the AASM class but we are accessing a DSL option already for the class.
43
+ aasm_klass = options[:with_klass] || AASM::Base
44
+
45
+ raise ArgumentError, "The class #{aasm_klass} must inherit from AASM::Base!" unless aasm_klass.ancestors.include?(AASM::Base)
46
+
47
+ @aasm ||= Concurrent::Map.new
48
+ if @aasm[state_machine_name]
49
+ # make sure to use provided options
50
+ options.each do |key, value|
51
+ @aasm[state_machine_name].state_machine.config.send("#{key}=", value)
52
+ end
53
+ else
54
+ # create a new base
55
+ @aasm[state_machine_name] = aasm_klass.new(
56
+ self,
57
+ state_machine_name,
58
+ AASM::StateMachineStore.fetch(self, true).machine(state_machine_name),
59
+ options
60
+ )
61
+ end
62
+ @aasm[state_machine_name].instance_eval(&block) if block # new DSL
63
+ @aasm[state_machine_name]
64
+ end
65
+ end # ClassMethods
66
+
67
+ # this is the entry point for all instance-level access to AASM
68
+ def aasm(name=:default)
69
+ unless AASM::StateMachineStore.fetch(self.class, true).machine(name)
70
+ raise AASM::UnknownStateMachineError.new("There is no state machine with the name '#{name}' defined in #{self.class.name}!")
71
+ end
72
+ @aasm ||= Concurrent::Map.new
73
+ @aasm[name.to_sym] ||= AASM::InstanceBase.new(self, name.to_sym)
74
+ end
75
+
76
+ def initialize_dup(other)
77
+ @aasm = Concurrent::Map.new
78
+ super
79
+ end
80
+
81
+ private
82
+
83
+ # Takes args and a from state and removes the first
84
+ # element from args if it is a valid to_state for
85
+ # the event given the from_state
86
+ def process_args(event, from_state, *args)
87
+ # If the first arg doesn't respond to to_sym then
88
+ # it isn't a symbol or string so it can't be a state
89
+ # name anyway
90
+ return args unless args.first.respond_to?(:to_sym)
91
+ if event.transitions_from_state(from_state).map(&:to).flatten.include?(args.first)
92
+ return args[1..-1]
93
+ end
94
+ return args
95
+ end
96
+
97
+ def aasm_fire_event(state_machine_name, event_name, options, *args, &block)
98
+ event = self.class.aasm(state_machine_name).state_machine.events[event_name]
99
+ begin
100
+ old_state = aasm(state_machine_name).state_object_for_name(aasm(state_machine_name).current_state)
101
+
102
+ fire_default_callbacks(event, *process_args(event, aasm(state_machine_name).current_state, *args))
103
+
104
+ if may_fire_to = event.may_fire?(self, *args)
105
+ fire_exit_callbacks(old_state, *process_args(event, aasm(state_machine_name).current_state, *args))
106
+ if new_state_name = event.fire(self, {:may_fire => may_fire_to}, *args)
107
+ aasm_fired(state_machine_name, event, old_state, new_state_name, options, *args, &block)
108
+ else
109
+ aasm_failed(state_machine_name, event_name, old_state, event.failed_callbacks)
110
+ end
111
+ else
112
+ aasm_failed(state_machine_name, event_name, old_state, event.failed_callbacks)
113
+ end
114
+ rescue StandardError => e
115
+ event.fire_callbacks(:error, self, e, *process_args(event, aasm(state_machine_name).current_state, *args)) ||
116
+ event.fire_global_callbacks(:error_on_all_events, self, e, *process_args(event, aasm(state_machine_name).current_state, *args)) ||
117
+ raise(e)
118
+ false
119
+ ensure
120
+ event.fire_callbacks(:ensure, self, *process_args(event, aasm(state_machine_name).current_state, *args))
121
+ event.fire_global_callbacks(:ensure_on_all_events, self, *process_args(event, aasm(state_machine_name).current_state, *args))
122
+ end
123
+ end
124
+
125
+ def fire_default_callbacks(event, *processed_args)
126
+ event.fire_global_callbacks(
127
+ :before_all_events,
128
+ self,
129
+ *processed_args
130
+ )
131
+
132
+ # new event before callback
133
+ event.fire_callbacks(
134
+ :before,
135
+ self,
136
+ *processed_args
137
+ )
138
+ end
139
+
140
+ def fire_exit_callbacks(old_state, *processed_args)
141
+ old_state.fire_callbacks(:before_exit, self, *processed_args)
142
+ old_state.fire_callbacks(:exit, self, *processed_args)
143
+ end
144
+
145
+ def aasm_fired(state_machine_name, event, old_state, new_state_name, options, *args)
146
+ persist = options[:persist]
147
+
148
+ new_state = aasm(state_machine_name).state_object_for_name(new_state_name)
149
+ callback_args = process_args(event, aasm(state_machine_name).current_state, *args)
150
+
151
+ new_state.fire_callbacks(:before_enter, self, *callback_args)
152
+
153
+ new_state.fire_callbacks(:enter, self, *callback_args) # TODO: remove for AASM 4?
154
+
155
+ persist_successful = true
156
+ if persist
157
+ persist_successful = aasm(state_machine_name).set_current_state_with_persistence(new_state_name)
158
+ if persist_successful
159
+ yield if block_given?
160
+ event.fire_callbacks(:before_success, self, *callback_args)
161
+ event.fire_transition_callbacks(self, *process_args(event, old_state.name, *args))
162
+ event.fire_callbacks(:success, self, *callback_args)
163
+ end
164
+ else
165
+ aasm(state_machine_name).current_state = new_state_name
166
+ yield if block_given?
167
+ end
168
+
169
+ binding_event = event.options[:binding_event]
170
+ if binding_event
171
+ __send__("#{binding_event}#{'!' if persist}")
172
+ end
173
+
174
+ if persist_successful
175
+ old_state.fire_callbacks(:after_exit, self, *callback_args)
176
+ new_state.fire_callbacks(:after_enter, self, *callback_args)
177
+ event.fire_callbacks(
178
+ :after,
179
+ self,
180
+ *process_args(event, old_state.name, *args)
181
+ )
182
+ event.fire_global_callbacks(
183
+ :after_all_events,
184
+ self,
185
+ *process_args(event, old_state.name, *args)
186
+ )
187
+
188
+ self.aasm_event_fired(event.name, old_state.name, aasm(state_machine_name).current_state) if self.respond_to?(:aasm_event_fired)
189
+ else
190
+ self.aasm_event_failed(event.name, old_state.name) if self.respond_to?(:aasm_event_failed)
191
+ end
192
+
193
+ persist_successful
194
+ end
195
+
196
+ def aasm_failed(state_machine_name, event_name, old_state, failures = [])
197
+ if self.respond_to?(:aasm_event_failed)
198
+ self.aasm_event_failed(event_name, old_state.name)
199
+ end
200
+
201
+ if AASM::StateMachineStore.fetch(self.class, true).machine(state_machine_name).config.whiny_transitions
202
+ raise AASM::InvalidTransition.new(self, event_name, state_machine_name, failures)
203
+ else
204
+ false
205
+ end
206
+ end
207
+
208
+ end
@@ -0,0 +1,300 @@
1
+ require 'logger'
2
+
3
+ module AASM
4
+ class Base
5
+
6
+ attr_reader :klass, :state_machine
7
+
8
+ def initialize(klass, name, state_machine, options={}, &block)
9
+ @klass = klass
10
+ @name = name
11
+ # @state_machine = klass.aasm(@name).state_machine
12
+ @state_machine = state_machine
13
+ @state_machine.config.column ||= (options[:column] || default_column).to_sym
14
+ # @state_machine.config.column = options[:column].to_sym if options[:column] # master
15
+ @options = options
16
+
17
+ # let's cry if the transition is invalid
18
+ configure :whiny_transitions, true
19
+
20
+ # create named scopes for each state
21
+ configure :create_scopes, true
22
+
23
+ # don't store any new state if the model is invalid (in ActiveRecord)
24
+ configure :skip_validation_on_save, false
25
+
26
+ # raise if the model is invalid (in ActiveRecord)
27
+ configure :whiny_persistence, true
28
+
29
+ # Use transactions (in ActiveRecord)
30
+ configure :use_transactions, true
31
+
32
+ # use requires_new for nested transactions (in ActiveRecord)
33
+ configure :requires_new_transaction, true
34
+
35
+ # use pessimistic locking (in ActiveRecord)
36
+ # true for FOR UPDATE lock
37
+ # string for a specific lock type i.e. FOR UPDATE NOWAIT
38
+ configure :requires_lock, false
39
+
40
+ # automatically set `"#{state_name}_at" = ::Time.now` on state changes
41
+ configure :timestamps, false
42
+
43
+ # set to true to forbid direct assignment of aasm_state column (in ActiveRecord)
44
+ configure :no_direct_assignment, false
45
+
46
+ # allow a AASM::Base sub-class to be used for state machine
47
+ configure :with_klass, AASM::Base
48
+
49
+ configure :enum, nil
50
+
51
+ # Set to true to namespace reader methods and constants
52
+ configure :namespace, false
53
+
54
+ # Configure a logger, with default being a Logger to STDERR
55
+ configure :logger, Logger.new(STDERR)
56
+
57
+ # setup timestamp-setting callback if enabled
58
+ setup_timestamps(@name)
59
+
60
+ # make sure to raise an error if no_direct_assignment is enabled
61
+ # and attribute is directly assigned though
62
+ setup_no_direct_assignment(@name)
63
+ end
64
+
65
+ # This method is both a getter and a setter
66
+ def attribute_name(column_name=nil)
67
+ if column_name
68
+ @state_machine.config.column = column_name.to_sym
69
+ else
70
+ @state_machine.config.column ||= :aasm_state
71
+ end
72
+ @state_machine.config.column
73
+ end
74
+
75
+ def initial_state(new_initial_state=nil)
76
+ if new_initial_state
77
+ @state_machine.initial_state = new_initial_state
78
+ else
79
+ @state_machine.initial_state
80
+ end
81
+ end
82
+
83
+ # define a state
84
+ # args
85
+ # [0] state
86
+ # [1] options (or nil)
87
+ # or
88
+ # [0] state
89
+ # [1..] state
90
+ def state(*args)
91
+ names, options = interpret_state_args(args)
92
+ names.each do |name|
93
+ @state_machine.add_state(name, klass, options)
94
+
95
+ aasm_name = @name.to_sym
96
+ state = name.to_sym
97
+
98
+ method_name = namespace? ? "#{namespace}_#{name}" : name
99
+ safely_define_method klass, "#{method_name}?", -> do
100
+ aasm(aasm_name).current_state == state
101
+ end
102
+
103
+ const_name = namespace? ? "STATE_#{namespace.upcase}_#{name.upcase}" : "STATE_#{name.upcase}"
104
+ unless klass.const_defined?(const_name)
105
+ klass.const_set(const_name, name)
106
+ end
107
+ end
108
+ end
109
+
110
+ # define an event
111
+ def event(name, options={}, &block)
112
+ @state_machine.add_event(name, options, &block)
113
+
114
+ aasm_name = @name.to_sym
115
+ event = name.to_sym
116
+
117
+ # Compute method name with namespace (mirrors how states work on line 98)
118
+ method_name = namespace? ? "#{name}_#{namespace}" : name
119
+
120
+ # an addition over standard aasm so that, before firing an event, you can ask
121
+ # may_event? and get back a boolean that tells you whether the guard method
122
+ # on the transition will let this happen.
123
+ safely_define_method klass, "may_#{method_name}?", ->(*args) do
124
+ aasm(aasm_name).may_fire_event?(event, *args)
125
+ end
126
+
127
+ safely_define_method klass, "#{method_name}!", ->(*args, &block) do
128
+ aasm(aasm_name).current_event = :"#{name}!"
129
+ aasm_fire_event(aasm_name, event, {:persist => true}, *args, &block)
130
+ end
131
+
132
+ safely_define_method klass, method_name, ->(*args, &block) do
133
+ aasm(aasm_name).current_event = event
134
+ aasm_fire_event(aasm_name, event, {:persist => false}, *args, &block)
135
+ end
136
+
137
+ skip_instance_level_validation(event, name, aasm_name, klass)
138
+
139
+ end
140
+
141
+ def after_all_transitions(*callbacks, &block)
142
+ @state_machine.add_global_callbacks(:after_all_transitions, *callbacks, &block)
143
+ end
144
+
145
+ def after_all_transactions(*callbacks, &block)
146
+ @state_machine.add_global_callbacks(:after_all_transactions, *callbacks, &block)
147
+ end
148
+
149
+ def before_all_transactions(*callbacks, &block)
150
+ @state_machine.add_global_callbacks(:before_all_transactions, *callbacks, &block)
151
+ end
152
+
153
+ def before_all_events(*callbacks, &block)
154
+ @state_machine.add_global_callbacks(:before_all_events, *callbacks, &block)
155
+ end
156
+
157
+ def after_all_events(*callbacks, &block)
158
+ @state_machine.add_global_callbacks(:after_all_events, *callbacks, &block)
159
+ end
160
+
161
+ def error_on_all_events(*callbacks, &block)
162
+ @state_machine.add_global_callbacks(:error_on_all_events, *callbacks, &block)
163
+ end
164
+
165
+ def ensure_on_all_events(*callbacks, &block)
166
+ @state_machine.add_global_callbacks(:ensure_on_all_events, *callbacks, &block)
167
+ end
168
+
169
+ def states
170
+ @state_machine.states
171
+ end
172
+
173
+ def events
174
+ @state_machine.events.values
175
+ end
176
+
177
+ # aasm.event(:event_name).human?
178
+ def human_event_name(event) # event_name?
179
+ AASM::Localizer.new.human_event_name(klass, event)
180
+ end
181
+
182
+ def states_for_select
183
+ states.map { |state| state.for_select }
184
+ end
185
+
186
+ def from_states_for_state(state, options={})
187
+ if options[:transition]
188
+ @state_machine.events[options[:transition]].transitions_to_state(state).flatten.map(&:from).flatten
189
+ else
190
+
191
+ events.map {|e| e.transitions_to_state(state)}.flatten.map(&:from).flatten
192
+ end
193
+ end
194
+
195
+ private
196
+
197
+ def default_column
198
+ @name.to_sym == :default ? :aasm_state : @name.to_sym
199
+ end
200
+
201
+ def configure(key, default_value)
202
+ if @options.key?(key)
203
+ @state_machine.config.send("#{key}=", @options[key])
204
+ elsif @state_machine.config.send(key).nil?
205
+ @state_machine.config.send("#{key}=", default_value)
206
+ end
207
+ end
208
+
209
+ def safely_define_method(klass, method_name, method_definition)
210
+ # Warn if method exists and it did not originate from an enum
211
+ if klass.method_defined?(method_name) &&
212
+ ! ( @state_machine.config.enum &&
213
+ klass.respond_to?(:defined_enums) &&
214
+ klass.defined_enums.values.any?{ |methods|
215
+ methods.keys{| enum | enum + '?' == method_name }
216
+ })
217
+ unless AASM::Configuration.hide_warnings
218
+ @state_machine.config.logger.warn "#{klass.name}: overriding method '#{method_name}'!"
219
+ end
220
+ end
221
+
222
+ klass.send(:define_method, method_name, method_definition).tap do |sym|
223
+ apply_ruby2_keyword(klass, sym)
224
+ end
225
+ end
226
+
227
+ def apply_ruby2_keyword(klass, sym)
228
+ if RUBY_VERSION >= '2.7.1'
229
+ if klass.instance_method(sym).parameters.find { |type, _| type.to_s.start_with?('rest') }
230
+ # If there is a place where you are receiving in *args, do ruby2_keywords.
231
+ klass.module_eval do
232
+ ruby2_keywords sym
233
+ end
234
+ end
235
+ end
236
+ end
237
+
238
+ def namespace?
239
+ !!@state_machine.config.namespace
240
+ end
241
+
242
+ def namespace
243
+ if @state_machine.config.namespace == true
244
+ @name
245
+ else
246
+ @state_machine.config.namespace
247
+ end
248
+ end
249
+
250
+ def interpret_state_args(args)
251
+ if args.last.is_a?(Hash) && args.size == 2
252
+ [[args.first], args.last]
253
+ elsif args.size > 0
254
+ [args, {}]
255
+ else
256
+ raise "count not parse states: #{args}"
257
+ end
258
+ end
259
+
260
+ def skip_instance_level_validation(event, name, aasm_name, klass)
261
+ # Overrides the skip_validation config for an instance (If skip validation is set to false in original config) and
262
+ # restores it back to the original value after the event is fired.
263
+ method_name = namespace? ? "#{name}_#{namespace}" : name
264
+ safely_define_method klass, "#{method_name}_without_validation!", ->(*args, &block) do
265
+ original_config = AASM::StateMachineStore.fetch(self.class, true).machine(aasm_name).config.skip_validation_on_save
266
+ begin
267
+ AASM::StateMachineStore.fetch(self.class, true).machine(aasm_name).config.skip_validation_on_save = true unless original_config
268
+ aasm(aasm_name).current_event = :"#{name}!"
269
+ aasm_fire_event(aasm_name, event, {:persist => true}, *args, &block)
270
+ ensure
271
+ AASM::StateMachineStore.fetch(self.class, true).machine(aasm_name).config.skip_validation_on_save = original_config
272
+ end
273
+ end
274
+ end
275
+
276
+ def setup_timestamps(aasm_name)
277
+ return unless @state_machine.config.timestamps
278
+
279
+ after_all_transitions do
280
+ if self.class.aasm(:"#{aasm_name}").state_machine.config.timestamps
281
+ ts_setter = "#{aasm(aasm_name).to_state}_at="
282
+ respond_to?(ts_setter) && send(ts_setter, ::Time.now)
283
+ end
284
+ end
285
+ end
286
+
287
+ def setup_no_direct_assignment(aasm_name)
288
+ return unless @state_machine.config.no_direct_assignment
289
+
290
+ @klass.send(:define_method, "#{@state_machine.config.column}=") do |state_name|
291
+ if self.class.aasm(:"#{aasm_name}").state_machine.config.no_direct_assignment
292
+ raise AASM::NoDirectAssignmentError.new('direct assignment of AASM column has been disabled (see AASM configuration for this class)')
293
+ else
294
+ super(state_name)
295
+ end
296
+ end
297
+ end
298
+
299
+ end
300
+ end
@@ -0,0 +1,48 @@
1
+ module AASM
2
+ class Configuration
3
+ # for all persistence layers: which database column to use?
4
+ attr_accessor :column
5
+
6
+ # let's cry if the transition is invalid
7
+ attr_accessor :whiny_transitions
8
+
9
+ # for all persistence layers: create named scopes for each state
10
+ attr_accessor :create_scopes
11
+
12
+ # for ActiveRecord: when the model is invalid, true -> raise, false -> return false
13
+ attr_accessor :whiny_persistence
14
+
15
+ # for ActiveRecord: store the new state even if the model is invalid and return true
16
+ attr_accessor :skip_validation_on_save
17
+
18
+ # for ActiveRecord: use transactions
19
+ attr_accessor :use_transactions
20
+
21
+ # for ActiveRecord: use requires_new for nested transactions?
22
+ attr_accessor :requires_new_transaction
23
+
24
+ # for ActiveRecord: use pessimistic locking
25
+ attr_accessor :requires_lock
26
+
27
+ # automatically set `"#{state_name}_at" = ::Time.now` on state changes
28
+ attr_accessor :timestamps
29
+
30
+ # forbid direct assignment in aasm_state column (in ActiveRecord)
31
+ attr_accessor :no_direct_assignment
32
+
33
+ # allow a AASM::Base sub-class to be used for state machine
34
+ attr_accessor :with_klass
35
+
36
+ attr_accessor :enum
37
+
38
+ # namespace reader methods and constants
39
+ attr_accessor :namespace
40
+
41
+ # Configure a logger, with default being a Logger to STDERR
42
+ attr_accessor :logger
43
+
44
+ class << self
45
+ attr_accessor :hide_warnings
46
+ end
47
+ end
48
+ end