mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Fixed an issue due to RubyMotion Proc's lack of 'source_location' method.
This may have some impact on debugging for RubyMotion, I would recommend using symbols to define guardians and callbacks whenever possible.
This commit is contained in:
parent
d3ad597f69
commit
5332ffe079
2 changed files with 11 additions and 3 deletions
|
@ -754,8 +754,12 @@ Job.aasm.states_for_select
|
|||
|
||||
To use AASM with a RubyMotion project, use it with the [motion-bundler](https://github.com/archan937/motion-bundler) gem.
|
||||
|
||||
Warning: Due to the way key-value observation (KVO) works in iOS,
|
||||
Warnings:
|
||||
- Due to the way key-value observation (KVO) works in iOS,
|
||||
you currently CANNOT use AASM with an object you are observing. (Yes.. that's pretty sad).
|
||||
- Due to RubyMotion Proc's lack of 'source_location' method, it may be harder
|
||||
to find out the origin of a "cannot transition from" error. I would recommend using
|
||||
the 'instance method symbol / string' way whenever possible when defining guardians and callbacks.
|
||||
|
||||
|
||||
### Testing
|
||||
|
|
|
@ -62,14 +62,18 @@ module AASM::Core
|
|||
# we should pass the arguments or not, since its does return 0 even in
|
||||
# presence of optional parameters.
|
||||
result = (code.parameters.size == 0 ? record.instance_exec(&code) : record.instance_exec(*args, &code))
|
||||
|
||||
failures << code.source_location.join('#') unless result
|
||||
else
|
||||
# In RubyMotion's Proc, the parameter method does not exists, however its
|
||||
# In RubyMotion's Proc, the 'parameter' method does not exists, however its
|
||||
# 'arity' method works just like the one from Method, only returning 0 when
|
||||
# there is no parameters whatsoever, optional or not.
|
||||
result = (code.arity == 0 ? record.instance_exec(&code) : record.instance_exec(*args, &code))
|
||||
|
||||
# Sadly, RubyMotion's Proc does not define the method 'source_location' either.
|
||||
failures << code unless result
|
||||
end
|
||||
|
||||
failures << code.source_location.join('#') unless result
|
||||
result
|
||||
when Array
|
||||
if options[:guard]
|
||||
|
|
Loading…
Add table
Reference in a new issue