Skip to content

Commit

Permalink
Merge pull request #4089 from envato/ruby-3-prep
Browse files Browse the repository at this point in the history
Align `as_json` method (use args instead of kwargs)
  • Loading branch information
grosser authored Feb 11, 2024
2 parents 5b372e5 + 1b199c8 commit 3f63338
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions app/models/concerns/attr_encrypted_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion plugins/env/app/models/environment_variable_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3f63338

Please sign in to comment.