module Clearly::Query::Compose::Core
Provides 'and', and 'or' for composing queries.
Private Instance Methods
Join conditions using and. @param [Arel::Nodes::Node] first_condition @param [Arel::Nodes::Node] second_condition @param [Array<Arel::Nodes::Node>] conditions @return [Arel::Nodes::Node] condition
# File lib/clearly/query/compose/core.rb, line 50 def compose_and(first_condition, second_condition, *conditions) validate_condition(first_condition) validate_condition(second_condition) combined = first_condition.and(second_condition) unless conditions.blank? conditions.each do |condition| combined = combined.and(condition) end end combined end
Join conditions using not. @param [Arel::Nodes::Node] condition @return [Arel::Nodes::Node] condition
# File lib/clearly/query/compose/core.rb, line 67 def compose_not(condition) validate_condition(condition) condition.not end
Join conditions using or. @param [Arel::Nodes::Node] first_condition @param [Arel::Nodes::Node] second_condition @return [Arel::Nodes::Node] condition
# File lib/clearly/query/compose/core.rb, line 39 def compose_or(first_condition, second_condition) validate_condition(first_condition) validate_condition(second_condition) first_condition.or(second_condition) end
Get the ActiveRecord::Relation that represents all records. @param [ActiveRecord::Base] model @return [ActiveRecord::Relation] query that will get all records
# File lib/clearly/query/compose/core.rb, line 22 def relation_all(model) validate_model(model) model.all end
Get the ActiveRecord::Relation that represents zero records. @param [ActiveRecord::Base] model @return [ActiveRecord::Relation] query that will get zero records
# File lib/clearly/query/compose/core.rb, line 14 def relation_none(model) validate_model(model) model.none end
Get the Arel::Table for this model. @param [ActiveRecord::Base] model @return [Arel::Table] arel table
# File lib/clearly/query/compose/core.rb, line 30 def relation_table(model) validate_model(model) model.arel_table end