Sha256: 44e3dc29ae8aeb6c4ec04643cd596dd735f5da94d7f878130e4b5b9c73262fdc

Contents?: true

Size: 353 Bytes

Versions: 10

Compression:

Stored size: 353 Bytes

Contents

module Agilibox::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, Agilibox::ActiveRecordCommaTypeCast)
ActiveRecord::Type::Float.send(:prepend, Agilibox::ActiveRecordCommaTypeCast)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
agilibox-1.0.9 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.8 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.7 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.6 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.5 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.4 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.3 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.2 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.1 lib/agilibox/active_record_comma_type_cast.rb
agilibox-1.0.0 lib/agilibox/active_record_comma_type_cast.rb