Class: Arel::Where
- Defined in:
- lib/arel/algebra/relations/operations/where.rb,
lib/arel/engines/memory/relations/operations.rb
Instance Attribute Summary
Attributes inherited from Compound
Attributes included from Relation
Instance Method Summary collapse
- #eval ⇒ Object
-
#initialize(relation, *predicates, &block) ⇒ Where
constructor
A new instance of Where.
- #wheres ⇒ Object
Methods inherited from Compound
#attributes, #build_query, #engine, #eql?, #hash, requires, #unoperated_rows
Methods included from Relation
#bind, #call, #christener, #compiler, #exclusion_predicate_sql, #externalizable?, #externalize, #inclusion_predicate_sql, #join?, #primary_key, #session, #to_sql
Methods included from Relation::DefaultOperations
#attributes, #groupings, #havings, #inserts, #joins, #locked, #orders, #projections, #skipped, #sources, #taken
Methods included from Relation::AttributeAccessable
#[], #find_attribute_matching_attribute, #find_attribute_matching_name, #position_of
Methods included from Relation::Operable
#alias, #join, #lock, #outer_join
Methods included from Relation::Operable::Writable
Methods included from Relation::Enumerable
Constructor Details
#initialize(relation, *predicates, &block) ⇒ Where
Returns a new instance of Where.
7 8 9 10 11 |
# File 'lib/arel/algebra/relations/operations/where.rb', line 7 def initialize(relation, *predicates, &block) predicates = [yield(relation)] + predicates if block_given? @predicates = predicates.map { |p| p.bind(relation) } @relation = relation end |
Instance Method Details
#eval ⇒ Object
3 4 5 |
# File 'lib/arel/engines/memory/relations/operations.rb', line 3 def eval unoperated_rows.select { |row| predicates.all? { |p| p.eval(row) } } end |
#wheres ⇒ Object
13 14 15 |
# File 'lib/arel/algebra/relations/operations/where.rb', line 13 def wheres @wheres ||= relation.wheres + predicates end |