Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed frozen string bug

  • Loading branch information...
commit c01304107808ddce5a3d734d4402bad35685c3e1 1 parent 226bcb1
@rafaelrosafu authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/i18n_localize_core/string_extensions.rb
View
8 lib/i18n_localize_core/string_extensions.rb
@@ -1,20 +1,22 @@
class String
def as_delocalized_number
- result = self.clone
+ # Using dup to avoid problems with frozen strings
+ result = self.dup
result.gsub!(I18n.thousand_separator, '_') if I18n.thousand_separator
result.gsub!(I18n.decimal_separator, '.') if I18n.decimal_separator
result
end
-
+
alias original_to_f to_f
def to_f(localize = nil)
localize = I18n.localize_core if localize.nil?
(localize ? as_delocalized_number : self).original_to_f
end
-
+
alias original_to_i to_i
def to_i(localize = nil)
localize = I18n.localize_core if localize.nil?
(localize ? as_delocalized_number : self).original_to_i
end
end
+
Please sign in to comment.
Something went wrong with that request. Please try again.