Skip to content

Commit 9ff803c

Browse files
committed
Extract method
1 parent d4f097a commit 9ff803c

File tree

1 file changed

+7
-3
lines changed
  • lib/ajax-datatables-rails/datatable/column

1 file changed

+7
-3
lines changed

lib/ajax-datatables-rails/datatable/column/search.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def non_regex_search
6262
when :eq, :not_eq, :lt, :gt, :lteq, :gteq, :in
6363
searchable_integer? ? raw_search(cond) : empty_search
6464
when :start_with
65-
casted_column.matches("#{formatted_value}%")
65+
text_search("#{formatted_value}%")
6666
when :end_with
67-
casted_column.matches("%#{formatted_value}")
67+
text_search("%#{formatted_value}")
6868
when :like
69-
casted_column.matches("%#{formatted_value}%")
69+
text_search("%#{formatted_value}%")
7070
when :string_eq
7171
raw_search(:eq)
7272
when :string_in
@@ -95,6 +95,10 @@ def raw_search(cond)
9595
end
9696
end
9797

98+
def text_search(value)
99+
casted_column.matches(value)
100+
end
101+
98102
def empty_search
99103
casted_column.matches(EMPTY_VALUE)
100104
end

0 commit comments

Comments
 (0)