module ActiveRecord::QueryMethods

Constants

CLAUSE_METHODS

Public Instance Methods

bind_values() click to toggle source
# File lib/where-or.rb, line 60
def bind_values
  where_clause.binds
end
bind_values=(values) click to toggle source
# File lib/where-or.rb, line 64
def bind_values=(values)
  self.where_clause = ActiveRecord::Relation::WhereClause.new(where_clause.predicates, values || [])
end
having_values() click to toggle source
# File lib/where-or.rb, line 52
def having_values
  having_clause.predicates
end
having_values=(values) click to toggle source
# File lib/where-or.rb, line 56
def having_values=(values)
  self.having_clause = ActiveRecord::Relation::WhereClause.new(values || [], having_clause.binds)
end
or(other) click to toggle source

Returns a new relation, which is the logical union of this relation and the one passed as an argument.

The two relations must be structurally compatible: they must be scoping the same model, and they must differ only by where (if no group has been defined) or having (if a group is present). Neither relation may have a limit, offset, or distinct set.

Post.where("id = 1").or(Post.where("id = 2"))
# SELECT `posts`.* FROM `posts`  WHERE (('id = 1' OR 'id = 2'))
# File lib/where-or.rb, line 78
def or(other)
  spawn.or!(other)
end
where_values() click to toggle source
# File lib/where-or.rb, line 44
def where_values
  where_clause.predicates
end
where_values=(values) click to toggle source
# File lib/where-or.rb, line 48
def where_values=(values)
  self.where_clause = ActiveRecord::Relation::WhereClause.new(values || [], where_clause.binds)
end

Private Instance Methods

new_having_clause()
Alias for: new_where_clause
new_where_clause() click to toggle source
# File lib/where-or.rb, line 104
def new_where_clause
  ActiveRecord::Relation::WhereClause.empty
end
Also aliased as: new_having_clause