Skip to content

Commit

Permalink
whitespace ninja
Browse files Browse the repository at this point in the history
  • Loading branch information
ttilley committed Jan 17, 2010
1 parent 0ea001f commit bb32281
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions lib/aasm/aasm.rb
Expand Up @@ -125,12 +125,12 @@ def aasm_current_state=(state)

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

Expand All @@ -144,7 +144,7 @@ def aasm_fire_event(name, persist, *args)
event = self.class.aasm_events[name]
begin
old_state = aasm_state_object_for_state(aasm_current_state)


old_state.call_action(:exit, self)

Expand Down
54 changes: 27 additions & 27 deletions lib/aasm/event.rb
Expand Up @@ -50,19 +50,19 @@ def ==(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
Expand All @@ -76,21 +76,21 @@ def execute_success_callback(obj, success = nil)
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
Expand Down
16 changes: 8 additions & 8 deletions lib/aasm/state.rb
Expand Up @@ -14,14 +14,14 @@ def ==(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
Expand Down

0 comments on commit bb32281

Please sign in to comment.