Sha256: 4859c966617a7adb10ad57af4f8813b5db060a2ad4155ff4e8cd0fb15168a7eb

Contents?: true

Size: 327 Bytes

Versions: 15

Compression:

Stored size: 327 Bytes

Contents

module ActiveRecordCommaTypeCast
  def cast_value(value)
    if value.is_a?(String)
      super value.gsub(",", ".").gsub(/[^-0-9\.]/, "")
    else
      super value
    end
  end
end

ActiveRecord::Type::Decimal.send(:prepend, ::ActiveRecordCommaTypeCast)
ActiveRecord::Type::Float.send(:prepend, ::ActiveRecordCommaTypeCast)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dorsale-3.3.0 lib/active_record_comma_type_cast.rb
dorsale-3.2.0 lib/active_record_comma_type_cast.rb
dorsale-3.1.7 lib/active_record_comma_type_cast.rb
dorsale-3.1.6 lib/active_record_comma_type_cast.rb
dorsale-3.1.5 lib/active_record_comma_type_cast.rb
dorsale-3.1.4 lib/active_record_comma_type_cast.rb
dorsale-3.1.3 lib/active_record_comma_type_cast.rb
dorsale-3.1.2 lib/active_record_comma_type_cast.rb
dorsale-3.1.1 lib/active_record_comma_type_cast.rb
dorsale-3.1.0 lib/active_record_comma_type_cast.rb
dorsale-3.0.3 lib/active_record_comma_type_cast.rb
dorsale-3.0.2 lib/active_record_comma_type_cast.rb
dorsale-3.0.1 lib/active_record_comma_type_cast.rb
dorsale-3.0.0 lib/active_record_comma_type_cast.rb
dorsale-2.7.3 lib/active_record_comma_type_cast.rb