Sha256: cd190ee1081b4b23a6036c596d72b466cc128d3b7ccf146df609c43d2216b3b4

Contents?: true

Size: 439 Bytes

Versions: 3

Compression:

Stored size: 439 Bytes

Contents

module Searchable
  def where(params)
    where_line = params.keys.map do |key|
      "#{key} = INTERPOLATOR_MARK"
    end
    where_line = where_line.join(' AND ')
    param_values = params.values

    data = MonoRM::DBConnection.execute(<<-SQL, *param_values)
      SELECT
        *
      FROM
        #{self.table_name}
      WHERE
        #{where_line}
    SQL
    parse_all(data)
  end
end

class MonoRM::Base
  extend Searchable
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
monorm-1.0.0 lib/monorm/searchable.rb
monorm-0.1.1 lib/monorm/searchable.rb
monorm-0.1.0 lib/monorm/searchable.rb