我有一种方法可以遍历哈希,.map以创建另一个哈希作为结果。
def assigned_task_list
assigned_tasks.map do |issue|
{
key: issue.key,
desired_time_to_resolution: issue.customfield_14777.dig('ongoingCycle', 'remainingTime', 'friendly'),
time_to_resolution: issue.customfield_10031.dig('ongoingCycle', 'remainingTime', 'friendly'),
name: issue.name
}
end
end
如何将 if 块放入此哈希中以决定放在那里desired_time_to_resolution:或time_to_resolution?
我的意思是如果像这样阻止:
if issue.customfield_14777.nil?
desired_time_to_resolution: issue.customfield_14777.dig('ongoingCycle', 'remainingTime', 'friendly')
else
time_to_resolution: issue.customfield_10031.dig('ongoingCycle', 'remainingTime', 'friendly')
end