Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tallty_import_export
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
tallty_import_export
Commits
b4f484ea
Commit
b4f484ea
authored
Mar 30, 2022
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: support json with prefix try_method
parent
9c6b1aa0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
export.rb
lib/tallty_import_export/export.rb
+4
-5
No files found.
lib/tallty_import_export/export.rb
View file @
b4f484ea
...
@@ -189,12 +189,10 @@ module TalltyImportExport
...
@@ -189,12 +189,10 @@ module TalltyImportExport
send
(
header
[
:method
],
record
,
header
)
send
(
header
[
:method
],
record
,
header
)
elsif
header
[
:chain
].
present?
elsif
header
[
:chain
].
present?
try_chain
(
record
,
header
[
:chain
])
try_chain
(
record
,
header
[
:chain
])
elsif
header
[
:json
]
record
.
send
(
header
[
:json
])[
header
[
:key
]]
elsif
header
[
:proc
]
&&
header
[
:proc
].
respond_to?
(
:call
)
elsif
header
[
:proc
]
&&
header
[
:proc
].
respond_to?
(
:call
)
header
[
:proc
].
call
(
record
,
context
)
header
[
:proc
].
call
(
record
,
context
)
else
else
try_method
(
record
,
header
[
:key
])
try_method
(
record
,
header
[
:key
]
,
prefix:
header
[
:json
]
)
end
end
data
=
handle_format
(
data
,
header
)
data
=
handle_format
(
data
,
header
)
data
=
handle_data_type
(
data
)
data
=
handle_data_type
(
data
)
...
@@ -207,9 +205,10 @@ module TalltyImportExport
...
@@ -207,9 +205,10 @@ module TalltyImportExport
arr
.
reduce
(
record
)
{
|
r
,
m
|
r
.
try
(
:[]
,
m
)
||
r
.
try
(
:[]
,
m
.
to_sym
)
||
r
.
try
(
m
)
}
arr
.
reduce
(
record
)
{
|
r
,
m
|
r
.
try
(
:[]
,
m
)
||
r
.
try
(
:[]
,
m
.
to_sym
)
||
r
.
try
(
m
)
}
end
end
def
try_method
record
,
method
def
try_method
record
,
method
,
prefix:
nil
arr
=
method
.
to_s
.
split
(
/\./
)
arr
=
method
.
to_s
.
split
(
/\./
)
try_chain
record
,
arr
prefix_arr
=
prefix
.
to_s
.
split
(
/\./
)
try_chain
record
,
arr
+
arr1
end
end
# 根据数据类型 attr_type 进行数据的格式化
# 根据数据类型 attr_type 进行数据的格式化
...
...
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