Commit eba1a437 by liyijie

feat: try_chain Hash logic

parent 3f32f36b
...@@ -236,22 +236,24 @@ module TalltyImportExport ...@@ -236,22 +236,24 @@ module TalltyImportExport
arr.reduce(record) do |r, m| arr.reduce(record) do |r, m|
if r.is_a?(Array) if r.is_a?(Array)
r.try(m) || r.try(:[], m.to_i) r.try(m) || r.try(:[], m.to_i)
elsif r.is_a?(Hash)
r.try(:[], m) || r.try(:[], m.to_sym)
else else
data = begin data = begin
r.try(:[], m) r.try(m)
rescue StandardError rescue StandardError
nil nil
end end
if data.nil? if data.nil?
data = begin data = begin
r.try(:[], m.to_sym) r.try(:[], m)
rescue StandardError rescue StandardError
nil nil
end end
end end
if data.nil? if data.nil?
data = begin data = begin
r.try(m) r.try(:[], m.to_sym)
rescue StandardError rescue StandardError
nil nil
end end
......
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