Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
7d590efa
Commit
7d590efa
authored
Apr 03, 2022
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 暂时去掉DslHelper::Proxy.class_eval
parent
66de4347
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
36 deletions
+36
-36
aasm_dlc.rb
lib/shotengai/aasm_dlc.rb
+36
-36
No files found.
lib/shotengai/aasm_dlc.rb
View file @
7d590efa
...
@@ -8,43 +8,43 @@ module Shotengai
...
@@ -8,43 +8,43 @@ module Shotengai
end
end
def
self
.
add_event_callbacks
def
self
.
add_event_callbacks
DslHelper
::
Proxy
.
class_eval
do
# DslHelper::Proxy.class_eval do
def
initialize
(
options
,
valid_keys
,
source
)
# original
@valid_keys
=
valid_keys
@source
=
source
# event or transition
@options
=
options
# dlc
expend_options
if
AASM
::
Core
::
Event
===
source
end
def
expend_options
preset_methods
=
[]
# add callbacks for valid_keys to definite event
# vaild_keys in aasm 4.12.2
# [ :after, :after_commit, :after_transaction, :before,
# :before_transaction, :ensure, :error, :before_success, :success ]
# e.g.
# event :pay ---> :after_pay, after_commit_pay ...
#
#
# NOTE: QUESTION: add key :error would cancel all exception ?
# def initialize(options, valid_keys, source)
(
@valid_keys
-
[
:error
,
:ensure
]).
each
do
|
callback
|
# # original
preset_methods
<<
"
#{
callback
}
_
#{
@source
.
name
}
"
# @valid_keys = valid_keys
@options
[
callback
]
=
Array
(
@options
[
callback
])
<<
"
#{
callback
}
_
#{
@source
.
name
}
"
# @source = source # event or transition
end
# @options = options
# # dlc
# ignore the method missing if it was in preset_methods
# expend_options if AASM::Core::Event === source
@source
.
class_eval
(
"
# end
def invoke_callbacks(code, record, args)
#
super(code, record, args)
# def expend_options
rescue NoMethodError
# preset_methods = []
code.to_s.in?(
#{
preset_methods
}
) ? true : raise
# # add callbacks for valid_keys to definite event
end
# # vaild_keys in aasm 4.12.2
"
)
# # [ :after, :after_commit, :after_transaction, :before,
end
# # :before_transaction, :ensure, :error, :before_success, :success ]
# # e.g.
end
# # event :pay ---> :after_pay, after_commit_pay ...
# #
# # NOTE: QUESTION: add key :error would cancel all exception ?
# (@valid_keys - [:error, :ensure]).each do |callback|
# preset_methods << "#{callback}_#{@source.name}"
# @options[callback] = Array(@options[callback]) << "#{callback}_#{@source.name}"
# end
#
# # ignore the method missing if it was in preset_methods
# @source.class_eval("
# def invoke_callbacks(code, record, args)
# super(code, record, args)
# rescue NoMethodError
# code.to_s.in?(#{preset_methods}) ? true : raise
# end
# ")
# end
#
# end
end
end
# module ClassMethods
# module ClassMethods
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment