module AjaxDatatablesRails::Datatable::Column::Search

Constants

EMPTY_VALUE
LARGEST_PQ_INTEGER
NOT_NULL_VALUE
SMALLEST_PQ_INTEGER

Public Instance Methods

cond() click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 17
def cond
  @view_column.fetch(:cond, :like)
end
filter() click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 21
def filter
  @view_column[:cond].call(self, formatted_value)
end
search_query() click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 33
def search_query
  search.regexp? ? regex_search : non_regex_search
end
searchable?() click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 13
def searchable?
  @view_column.fetch(:searchable, true)
end
searched?() click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 29
def searched?
  search.value.present?
end
use_regex?() click to toggle source

Add use_regex option to allow bypassing of regex search

# File lib/ajax-datatables-rails/datatable/column/search.rb, line 38
def use_regex?
  @view_column.fetch(:use_regex, true)
end

Private Instance Methods

integer?(string) click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 115
def integer?(string)
  Integer(string)
  true
rescue ArgumentError
  false
end
out_of_range?(search_value) click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 111
def out_of_range?(search_value)
  Integer(search_value) > LARGEST_PQ_INTEGER || Integer(search_value) < SMALLEST_PQ_INTEGER
end
searchable_integer?() click to toggle source
# File lib/ajax-datatables-rails/datatable/column/search.rb, line 102
def searchable_integer?
  if formatted_value.is_a?(Array)
    valids = formatted_value.map { |v| integer?(v) && !out_of_range?(v) }
    !valids.include?(false)
  else
    integer?(formatted_value) && !out_of_range?(formatted_value)
  end
end