Skip to content

Commit

Permalink
Merge 6863096 into 82f592a
Browse files Browse the repository at this point in the history
  • Loading branch information
Infotaku committed Feb 9, 2016
2 parents 82f592a + 6863096 commit e716939
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/aasm/core/transition.rb
Expand Up @@ -53,13 +53,13 @@ def invoke_callbacks_compatible_with_guard(code, record, args, options={})

case code
when Symbol, String
result = (record.__send__(:method, code.to_sym).arity == 0 ? record.__send__(code) : result = record.__send__(code, *args))
result = (record.__send__(:method, code.to_sym).arity == 0 ? record.__send__(code) : record.__send__(code, *args))
failures << code unless result
result
when Proc
if code.respond_to?(:parameters)
# In Ruby's Proc, the 'arity' method is not a good condidate to know if
# we should pass the arguments or not, since its does return 0 even in
# we should pass the arguments or not, since it does return 0 even in
# presence of optional parameters.
result = (code.parameters.size == 0 ? record.instance_exec(&code) : record.instance_exec(*args, &code))

Expand All @@ -85,7 +85,14 @@ def invoke_callbacks_compatible_with_guard(code, record, args, options={})
instance = code.new(record, *args)
end
result = instance.call
failures << instance.method(:call).source_location.join('#') unless result

if Method.method_defined?(:source_location)
failures << instance.method(:call).source_location.join('#') unless result
else
# RubyMotion support ('source_location' not defined for Method)
failures << instance.method(:call) unless result
end

result
when Array
if options[:guard]
Expand Down

0 comments on commit e716939

Please sign in to comment.