Skip to content

Commit

Permalink
Do not delete from frozen options passed to as_json
Browse files Browse the repository at this point in the history
  • Loading branch information
nvasilevski committed Sep 16, 2024
1 parent d09fc9e commit 8e070eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/money/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ def to_fs(style = nil)
alias_method :to_formatted_s, :to_fs

def to_json(options = nil)
if (options.is_a?(Hash) && options.delete(:legacy_format)) || Money.config.legacy_json_format
if (options.is_a?(Hash) && options[:legacy_format]) || Money.config.legacy_json_format
to_s
else
as_json(options).to_json
end
end

def as_json(options = nil)
if (options.is_a?(Hash) && options.delete(:legacy_format)) || Money.config.legacy_json_format
if (options.is_a?(Hash) && options[:legacy_format]) || Money.config.legacy_json_format
to_s
else
{ value: to_s(:amount), currency: currency.to_s }
Expand Down

0 comments on commit 8e070eb

Please sign in to comment.