mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
whitespace ninja
This commit is contained in:
parent
0ea001fe6e
commit
bb32281d2d
3 changed files with 42 additions and 42 deletions
|
@ -125,12 +125,12 @@ module AASM
|
|||
|
||||
def aasm_determine_state_name(state)
|
||||
case state
|
||||
when Symbol, String
|
||||
state
|
||||
when Proc
|
||||
state.call(self)
|
||||
else
|
||||
raise NotImplementedError, "Unrecognized state-type given. Expected Symbol, String, or Proc."
|
||||
when Symbol, String
|
||||
state
|
||||
when Proc
|
||||
state.call(self)
|
||||
else
|
||||
raise NotImplementedError, "Unrecognized state-type given. Expected Symbol, String, or Proc."
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -144,7 +144,7 @@ module AASM
|
|||
event = self.class.aasm_events[name]
|
||||
begin
|
||||
old_state = aasm_state_object_for_state(aasm_current_state)
|
||||
|
||||
|
||||
|
||||
old_state.call_action(:exit, self)
|
||||
|
||||
|
|
|
@ -50,19 +50,19 @@ class AASM::SupportingClasses::Event
|
|||
end
|
||||
end
|
||||
|
||||
def update(options = {}, &block)
|
||||
if options.key?(:success) then
|
||||
@success = options[:success]
|
||||
end
|
||||
if options.key?(:error) then
|
||||
@error = options[:error]
|
||||
end
|
||||
if block then
|
||||
instance_eval(&block)
|
||||
end
|
||||
@options = options
|
||||
self
|
||||
end
|
||||
def update(options = {}, &block)
|
||||
if options.key?(:success) then
|
||||
@success = options[:success]
|
||||
end
|
||||
if options.key?(:error) then
|
||||
@error = options[:error]
|
||||
end
|
||||
if block then
|
||||
instance_eval(&block)
|
||||
end
|
||||
@options = options
|
||||
self
|
||||
end
|
||||
|
||||
def execute_success_callback(obj, success = nil)
|
||||
callback = success || @success
|
||||
|
@ -76,21 +76,21 @@ class AASM::SupportingClasses::Event
|
|||
end
|
||||
end
|
||||
|
||||
def execute_error_callback(obj, error, error_callback=nil)
|
||||
callback = error_callback || @error
|
||||
raise error unless callback
|
||||
case(callback)
|
||||
when String, Symbol
|
||||
raise NoMethodError unless obj.respond_to?(callback.to_sym)
|
||||
obj.send(callback, error)
|
||||
when Proc
|
||||
callback.call(obj, error)
|
||||
when Array
|
||||
callback.each{|meth|self.execute_error_callback(obj, error, meth)}
|
||||
end
|
||||
end
|
||||
def execute_error_callback(obj, error, error_callback=nil)
|
||||
callback = error_callback || @error
|
||||
raise error unless callback
|
||||
case(callback)
|
||||
when String, Symbol
|
||||
raise NoMethodError unless obj.respond_to?(callback.to_sym)
|
||||
obj.send(callback, error)
|
||||
when Proc
|
||||
callback.call(obj, error)
|
||||
when Array
|
||||
callback.each{|meth|self.execute_error_callback(obj, error, meth)}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def _call_action(action, record)
|
||||
case action
|
||||
|
|
|
@ -14,14 +14,14 @@ class AASM::SupportingClasses::State
|
|||
end
|
||||
end
|
||||
|
||||
def call_action(action, record)
|
||||
action = @options[action]
|
||||
catch :halt_aasm_chain do
|
||||
action.is_a?(Array) ?
|
||||
action.each {|a| _call_action(a, record)} :
|
||||
_call_action(action, record)
|
||||
end
|
||||
end
|
||||
def call_action(action, record)
|
||||
action = @options[action]
|
||||
catch :halt_aasm_chain do
|
||||
action.is_a?(Array) ?
|
||||
action.each {|a| _call_action(a, record)} :
|
||||
_call_action(action, record)
|
||||
end
|
||||
end
|
||||
|
||||
def display_name
|
||||
@display_name ||= name.to_s.gsub(/_/, ' ').capitalize
|
||||
|
|
Loading…
Reference in a new issue