whitespace ninja

This commit is contained in:
Travis Tilley 2010-01-17 01:30:38 -05:00
parent 0ea001fe6e
commit bb32281d2d
3 changed files with 42 additions and 42 deletions

View File

@ -125,12 +125,12 @@ module AASM
def aasm_determine_state_name(state) def aasm_determine_state_name(state)
case state case state
when Symbol, String when Symbol, String
state state
when Proc when Proc
state.call(self) state.call(self)
else else
raise NotImplementedError, "Unrecognized state-type given. Expected Symbol, String, or Proc." raise NotImplementedError, "Unrecognized state-type given. Expected Symbol, String, or Proc."
end end
end end

View File

@ -50,19 +50,19 @@ class AASM::SupportingClasses::Event
end end
end end
def update(options = {}, &block) def update(options = {}, &block)
if options.key?(:success) then if options.key?(:success) then
@success = options[:success] @success = options[:success]
end end
if options.key?(:error) then if options.key?(:error) then
@error = options[:error] @error = options[:error]
end end
if block then if block then
instance_eval(&block) instance_eval(&block)
end end
@options = options @options = options
self self
end end
def execute_success_callback(obj, success = nil) def execute_success_callback(obj, success = nil)
callback = success || @success callback = success || @success
@ -76,21 +76,21 @@ class AASM::SupportingClasses::Event
end end
end end
def execute_error_callback(obj, error, error_callback=nil) def execute_error_callback(obj, error, error_callback=nil)
callback = error_callback || @error callback = error_callback || @error
raise error unless callback raise error unless callback
case(callback) case(callback)
when String, Symbol when String, Symbol
raise NoMethodError unless obj.respond_to?(callback.to_sym) raise NoMethodError unless obj.respond_to?(callback.to_sym)
obj.send(callback, error) obj.send(callback, error)
when Proc when Proc
callback.call(obj, error) callback.call(obj, error)
when Array when Array
callback.each{|meth|self.execute_error_callback(obj, error, meth)} callback.each{|meth|self.execute_error_callback(obj, error, meth)}
end end
end end
private private
def _call_action(action, record) def _call_action(action, record)
case action case action

View File

@ -14,14 +14,14 @@ class AASM::SupportingClasses::State
end end
end end
def call_action(action, record) def call_action(action, record)
action = @options[action] action = @options[action]
catch :halt_aasm_chain do catch :halt_aasm_chain do
action.is_a?(Array) ? action.is_a?(Array) ?
action.each {|a| _call_action(a, record)} : action.each {|a| _call_action(a, record)} :
_call_action(action, record) _call_action(action, record)
end end
end end
def display_name def display_name
@display_name ||= name.to_s.gsub(/_/, ' ').capitalize @display_name ||= name.to_s.gsub(/_/, ' ').capitalize