Module: ActiverecordExtensions::QueryBuilder

Defined in:
lib/activerecord-extensions/query_builder.rb

Instance Method Summary collapse

Instance Method Details

#where_gt(attribute, value) ⇒ Object



4
5
6
# File 'lib/activerecord-extensions/query_builder.rb', line 4

def where_gt(attribute, value)
  where_with_bind(arel_table[attribute].gt(Arel::Nodes::BindParam.new), {attribute => value})
end

#where_in(attribute, values) ⇒ Object



12
13
14
15
16
# File 'lib/activerecord-extensions/query_builder.rb', line 12

def where_in(attribute, values)
  bind_params = values.map{ Arel::Nodes::BindParam.new }
  column_values = values.each_with_object([]) { |value, column_values| column_values.push [attribute, value] }
  where_with_bind(arel_table[attribute].in(bind_params), column_values)
end

#where_lt(attribute, value) ⇒ Object



8
9
10
# File 'lib/activerecord-extensions/query_builder.rb', line 8

def where_lt(attribute, value)
  where_with_bind(arel_table[attribute].lt(Arel::Nodes::BindParam.new), {attribute => value})
end

#where_with_bind(clause, opt) ⇒ Object



18
19
20
# File 'lib/activerecord-extensions/query_builder.rb', line 18

def where_with_bind(clause, opt)
  where(clause).bind_parameters(opt)
end