Sha256: 2df6eb151a6c4ee0d17714d3a65d3deafd349679c944e6a0095deed3e931efd3

Contents?: true

Size: 351 Bytes

Versions: 40

Compression:

Stored size: 351 Bytes

Contents

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

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

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
agilibox-1.6.2 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.6.1 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.6.0 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.13 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.12 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.11 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.10 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.9 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.8 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.7 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.6 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.5 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.4 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.3 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.2 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.1 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.5.0 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.4.4 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.4.3 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.4.2 lib/agilibox/active_record_comma_type_cast.rb