Module: Searchable

Included in:
Bezel::BezelrecordBase
Defined in:
lib/bezelrecord_base/searchable.rb

Instance Method Summary collapse

Instance Method Details

#where(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/bezelrecord_base/searchable.rb', line 4

def where(params)
  where_line = params.keys.map{|key| "#{key} = ?"}
  results = DBConnection.execute(<<-SQL, *params.values)
    SELECT
      *
    FROM
      #{table_name}
    WHERE
      #{where_line.join(" AND ")}
  SQL
  parse_all(results)
end