Commit e78afef0 by liyijie

feat: update format

parent 7d2f8062
......@@ -238,23 +238,23 @@ module TalltyImportExport
''
end
def try_chain(payload, arr)
arr.reduce(payload) do |r, m|
if m =~ /^\d+$/ && r.is_a?(Array) # If m is an integer string and r is an array
r[m.to_i]
else
r.try(m) || r.try(:[], m)
def try_chain(payload, arr)
arr.reduce(payload) do |r, m|
if m =~ /^\d+$/ && r.is_a?(Array) # If m is an integer string and r is an array
r[m.to_i]
else
r.try(m) || r.try(:[], m)
end
rescue StandardError
nil
end
rescue StandardError
nil
end
end
def try_method(payload, method, prefix: nil)
prefix_arr = prefix.to_s.split(/\./)
arr = method.split('.').flat_map { |m| m.include?('[') ? m.split(/\[\s*|\s*\]/).reject(&:empty?) : m }
try_chain record, prefix_arr + arr
end
def try_method(payload, method, prefix: nil)
prefix_arr = prefix.to_s.split(/\./)
arr = method.split('.').flat_map { |m| m.include?('[') ? m.split(/\[\s*|\s*\]/).reject(&:empty?) : m }
try_chain record, prefix_arr + arr
end
# 根据数据类型 attr_type 进行数据的格式化
def handle_format(data, header, **opts)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment