Sha256: b0b1c21a6f50568267459677cdb480d9f506fe83092fe39218439880b5288968
Contents?: true
Size: 796 Bytes
Versions: 2
Compression:
Stored size: 796 Bytes
Contents
module Yap class Filter < Hash def initialize self[:where] = {} self[:not] = {} end def parse!(column, values) values.to_s.split(',').each do |value| # Perform negative match if value starts with '!'. if value =~/^!(.+)$/ match = :not value = $1 else match = :where end case value when /(.+)\.{3}(.+)/ value = $1...$2 when /(.+)\.{2}(.+)/ value = $1..$2 else # Convert null to ruby nil to use 'IS NULL' in SQL. value = value.downcase == 'null' ? nil : value end # Ensure filter contains an array to append to. self[match][column] ||= [] self[match][column] << value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yap-1.2.3 | lib/yap/filter.rb |
yap-1.2.2 | lib/yap/filter.rb |