Sha256: ce8e0b29898d8586c7db12e90cd6f4682a3e6e444d29970a4a565958995b4695
Contents?: true
Size: 665 Bytes
Versions: 2
Compression:
Stored size: 665 Bytes
Contents
require 'treetop' module Murlsh # Search conditions builder for ActiveRecord conditions. class SearchConditions def initialize(q); @q = q; end # Search conditions builder for ActiveRecord conditions. def conditions if q parser = Murlsh::SearchGrammarParser.new tokens = parser.parse(q).content search_cols = %w{name title url} likes = [] params = [] search_cols.product(tokens).each do |col,tok| likes << "#{col} LIKE ?" params << "%#{tok}%" end [likes.join(' OR ')].push(*params) else [] end end attr_accessor :q end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
murlsh-1.4.1 | lib/murlsh/search_conditions.rb |
murlsh-1.4.0 | lib/murlsh/search_conditions.rb |