Sha256: 43760db8c3641478f4717bb9775bb30201269f9d2ce8b7b250443cf2ba2be8eb
Contents?: true
Size: 425 Bytes
Versions: 1
Compression:
Stored size: 425 Bytes
Contents
require "frankensql/version" module Frankensql def self.search(table, params) @query = ["SELECT * FROM #{table} WHERE id > 0"] params.each_key{ |key| add_to_query(params[key], key) } @query.join(" ") end private def self.add_to_query(value, key) is_present?(value) ? (@query << "AND #{key} LIKE '%#{value}%'") : ("") end def self.is_present?(type) !type.empty? && !type.include?(";") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
frankensql-1.0.0 | lib/frankensql.rb |