examples/sequel_example.rb in search_lingo-2.0.0 vs examples/sequel_example.rb in search_lingo-3.0.0.pre1
- old
+ new
@@ -54,16 +54,14 @@
#
# 7/4/1776 => Tasks with due_date == Date.new(1776, 7, 4)
# 7/4/17 => Tasks with due_date == Date.new(2017, 7, 4)
parser do |token, chain|
token.match %r{\A(?<m>\d{1,2})/(?<d>\d{1,2})/(?<y>\d{2}\d{2}?)\z} do |m|
- begin
- date = Date.parse "#{m[:y]}/#{m[:m]}/#{m[:d]}"
- chain.where due_date: date
- rescue ArgumentError
- # Fail if Date.parse raises an ArgumentError
- nil
- end
+ date = Date.parse "#{m[:y]}/#{m[:m]}/#{m[:d]}"
+ chain.where due_date: date
+ rescue ArgumentError
+ # Fail if Date.parse raises an ArgumentError
+ nil
end
end
# Match tasks with names containing the given string.
def default_parse(token, chain)