Sha256: 153ad4fe2bb12d078128333d8d23b1c7f4333af767eab867009f7c994fbc6222
Contents?: true
Size: 773 Bytes
Versions: 35
Compression:
Stored size: 773 Bytes
Contents
module Effective module EffectiveDatatable module Helpers # When we order by Array, it's already a string. # This gives us a mechanism to sort numbers as numbers def convert_to_column_type(table_column, value) if value.html_safe? && value.kind_of?(String) && value.start_with?('<') value = ActionView::Base.full_sanitizer.sanitize(value) end case table_column[:type] when :number, :price, :decimal, :float, :percentage (value.to_s.gsub(/[^0-9|\.]/, '').to_f rescue 0.00) unless value.kind_of?(Numeric) when :integer (value.to_s.gsub(/\D/, '').to_i rescue 0) unless value.kind_of?(Integer) else ; # Do nothing end || value end end end end
Version data entries
35 entries across 35 versions & 1 rubygems