Skip to content

Commit f84441f

Browse files
author
Nicolas Rodriguez
committed
Extract method, coding style
1 parent 3f2a702 commit f84441f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,10 @@ def non_regex_search
129129
table[field].send(cond, value)
130130
end
131131
when :range
132-
if empty_range_search?
133-
nil
134-
else
135-
range_search
136-
end
132+
return nil if empty_range_search?
133+
range_search
137134
when :null_value
138-
if search.value == '!NULL'
139-
table[field].not_eq(nil)
140-
else
141-
table[field].eq(nil)
142-
end
135+
null_value_search
143136
when :start_with
144137
casted_column.matches("#{value}%")
145138
when :end_with
@@ -185,6 +178,14 @@ def range_search
185178
table[field].between(OpenStruct.new(begin: new_start, end: new_end))
186179
end
187180

181+
def null_value_search
182+
if search.value == '!NULL'
183+
table[field].not_eq(nil)
184+
else
185+
table[field].eq(nil)
186+
end
187+
end
188+
188189
end
189190
end
190191
end

0 commit comments

Comments
 (0)