Module: Searchable

Included in:
ModelBase
Defined in:
lib/reloj/orm/searchable.rb

Instance Method Summary collapse

Instance Method Details

#where(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reloj/orm/searchable.rb', line 6

def where(params)
  conditions = params.map do |key, value|
    "#{key} = ?"
  end.join(" AND ")
  result = DBConnection.execute(<<-SQL, params.values)
    SELECT
      *
    FROM
      #{self.table_name}
    WHERE
      #{conditions};
  SQL

  self.parse_all(result)
end