From e71ac70c3187dab27a4c1d8459fcf3fcae4776c2 Mon Sep 17 00:00:00 2001 From: Orien Madgwick <497874+orien@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:55:00 +1100 Subject: [PATCH] Align `as_json` method (use args instead of kwargs) --- app/models/concerns/attr_encrypted_support.rb | 7 ++++--- app/models/deploy.rb | 4 ++-- plugins/env/app/models/environment_variable_group.rb | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) 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