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
21ab10da
Commit
21ab10da
authored
Aug 29, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix AASM_DSL about the disable InvalidTranslation
parent
75149d8b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
aasm_dlc.rb
lib/shotengai/aasm_dlc.rb
+5
-5
order.rb
lib/shotengai/order.rb
+16
-9
No files found.
lib/shotengai/aasm_dlc.rb
View file @
21ab10da
...
@@ -27,18 +27,18 @@ module Shotengai
...
@@ -27,18 +27,18 @@ module Shotengai
# e.g.
# e.g.
# event :pay ---> :after_pay, after_commit_pay ...
# event :pay ---> :after_pay, after_commit_pay ...
#
#
@valid_keys
.
each
do
|
callback
|
# NOTE: QUESTION: add key :error would cancel all exception ?
(
@valid_keys
-
[
:error
,
:ensure
]).
each
do
|
callback
|
preset_methods
<<
"
#{
callback
}
_
#{
@source
.
name
}
"
preset_methods
<<
"
#{
callback
}
_
#{
@source
.
name
}
"
@options
[
callback
]
=
Array
(
@options
[
callback
])
<<
"
#{
callback
}
_
#{
@source
.
name
}
"
@options
[
callback
]
=
Array
(
@options
[
callback
])
<<
"
#{
callback
}
_
#{
@source
.
name
}
"
end
end
# ignore the method missing if it was in preset_methods
# ignore the method missing if it was in preset_methods
@source
.
class_eval
(
"
@source
.
class_eval
(
"
def invoke_callbacks(code, record, args)
def invoke_callbacks(code, record, args)
case code
when String, Symbol
return true if record.respond_to?(code, true).! && code.to_s.in?(
#{
preset_methods
}
)
end
super(code, record, args)
super(code, record, args)
rescue NoMethodError
code.to_s.in?(
#{
preset_methods
}
) ? true : raise
end
end
"
)
"
)
end
end
...
...
lib/shotengai/order.rb
View file @
21ab10da
...
@@ -33,21 +33,28 @@ module Shotengai
...
@@ -33,21 +33,28 @@ module Shotengai
belongs_to
:buyer
,
polymorphic:
true
,
optional:
true
belongs_to
:buyer
,
polymorphic:
true
,
optional:
true
default_scope
{
where
.
not
(
status:
'cart'
)
}
default_scope
{
where
.
not
(
status:
'cart'
)
}
scope
:status_is
,
->
(
status
)
{
where
(
status
.
blank?
.!
&&
{
status:
status
})
}
include
AASM_DLC
include
AASM_DLC
aasm
column: :status
do
aasm
column: :status
do
state
:unpaid
,
initial:
true
state
:unpaid
,
initial:
true
state
:paid
,
:delivering
,
:received
,
:evaluated
state
:paid
,
:delivering
,
:received
,
:evaluated
{
event
:pay
,
after:
[
:fill_snapshot
,
:set_pay_time
]
{
pay:
{
from: :unpaid
,
to: :paid
,
after:
[
:fill_snapshot
,
:set_pay_time
]
},
transitions
from: :unpaid
,
to: :paid
cancel:
{
from: :unpaid
,
to: :canceled
},
}
send_out:
{
from: :paid
,
to: :delivering
,
after: :set_delivery_time
},
event
:cancel
{
get_it:
{
from: :delivering
,
to: :received
,
after: :set_receipt_time
},
transitions
from: :unpaid
,
to: :canceled
evaluate:
{
from: :received
,
to: :evaluated
},
}
# soft_delete: { from: : to: :evaluated },
event
:send_out
,
after: :set_delivery_time
{
}.
each
{
|
name
,
options
|
transitions
from: :paid
,
to: :delivering
event
(
name
)
{
transitions
options
}
}
event
:get_it
,
after: :set_receipt_time
{
transitions
from: :delivering
,
to: :received
}
event
:evaluate
{
transitions
from: :received
,
to: :evaluated
}
}
# event :soft_delete
end
end
def
status_zh
def
status_zh
...
...
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