From 1d0bae2cf9ab3c493dc974cd06262a657eb608fb Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Wed, 14 Sep 2016 07:50:18 -0300 Subject: [PATCH] 9623: Moved deep_sort_hash method to ArvadosModel as it's used by both Job and Container classes. --- services/api/app/models/arvados_model.rb | 12 ++++++++++++ services/api/app/models/container.rb | 12 ------------ services/api/app/models/job.rb | 12 ------------ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index 51673f7acb..7d1c30cdaf 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -271,6 +271,18 @@ class ArvadosModel < ActiveRecord::Base protected + def self.deep_sort_hash(x) + if x.is_a? Hash + x.sort.collect do |k, v| + [k, deep_sort_hash(v)] + end.to_h + elsif x.is_a? Array + x.collect { |v| deep_sort_hash(v) } + else + x + end + end + def ensure_ownership_path_leads_to_user if new_record? or owner_uuid_changed? uuid_in_path = {owner_uuid => true, uuid => true} diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index c28a60481c..48d9e5fefc 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -150,18 +150,6 @@ class Container < ArvadosModel protected - def self.deep_sort_hash(x) - if x.is_a? Hash - x.sort.collect do |k, v| - [k, deep_sort_hash(v)] - end.to_h - elsif x.is_a? Array - x.collect { |v| deep_sort_hash(v) } - else - x - end - end - def fill_field_defaults self.state ||= Queued self.environment ||= {} diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb index e7d1b39ce9..30ca7f8cb2 100644 --- a/services/api/app/models/job.rb +++ b/services/api/app/models/job.rb @@ -282,18 +282,6 @@ class Job < ArvadosModel Digest::MD5.hexdigest(Oj.dump(deep_sort_hash(h))) end - def self.deep_sort_hash x - if x.is_a? Hash - x.sort.collect do |k, v| - [k, deep_sort_hash(v)] - end.to_h - elsif x.is_a? Array - x.collect { |v| deep_sort_hash(v) } - else - x - end - end - def foreign_key_attributes super + %w(output log) end -- 2.30.2