diff --git a/app/models/concerns/attr_encrypted_support.rb b/app/models/concerns/attr_encrypted_support.rb index 6ef24a622f..0a158b4912 100644 --- a/app/models/concerns/attr_encrypted_support.rb +++ b/app/models/concerns/attr_encrypted_support.rb @@ -11,14 +11,15 @@ def self.included(base) base.extend ClassMethods end - def as_json(except: [], **options) - except += [ + def as_json(options = {}) + options[:except] ||= [] + options[:except] += [ :encryption_key_sha, *self.class.encrypted_attributes.keys.flat_map do |column| [column, :"encrypted_#{column}_iv", :"encrypted_#{column}"] end ] - super(except: except, **options) + super(options) end private diff --git a/app/models/deploy.rb b/app/models/deploy.rb index e49f4dc5be..aefed6b292 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -231,8 +231,8 @@ def csv_line ] end - def as_json(methods: []) - hash = super(methods: [:status, :url, :production, :commit] + methods) + def as_json(options = {}) + hash = super({methods: [:status, :url, :production, :commit] + options.fetch(:methods, [])}) hash["summary"] = summary_for_timeline hash end diff --git a/plugins/env/app/models/environment_variable_group.rb b/plugins/env/app/models/environment_variable_group.rb index eb684e7261..ecacd6292b 100644 --- a/plugins/env/app/models/environment_variable_group.rb +++ b/plugins/env/app/models/environment_variable_group.rb @@ -22,7 +22,8 @@ def variable_names environment_variables.sort_by(&:id).map(&:name).uniq end - def as_json(methods: [], **options) + def as_json(options = {}) + methods = options.delete(:methods) || [] super({methods: [:variable_names] + methods}.merge(options)) end