Sha256: d7c72a7c1210b40ef2732b0a38ca1a1cdc482524ae3ad094660297757e3ee2a0
Contents?: true
Size: 938 Bytes
Versions: 1
Compression:
Stored size: 938 Bytes
Contents
require 'search_lingo/parsers/date_parser' require 'forwardable' module SearchLingo module Parsers class OpenDateRangeParser < DateParser extend Forwardable DATE_RANGE = /(?:-(?<max>#{US_DATE})|(?<min>#{US_DATE})-)/ def call(token) token.match /\A#{prefix}#{DATE_RANGE}\z/ do |m| if m[:max] date = parse m[:max] [ :where, "#{quote_table_name table}.#{quote_column_name column} <= ?", date ] if date else date = parse m[:min] [ :where, "#{quote_table_name table}.#{quote_column_name column} >= ?", date ] if date end end end def post_initialize(connection:, **) @connection = connection end def_delegators :@connection, :quote_column_name, :quote_table_name end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
search_lingo-1.0.1 | lib/search_lingo/parsers/open_date_range_parser.rb |