Class: Neo4j::Core::Query::PartitionedClauses
- Inherits:
-
Object
- Object
- Neo4j::Core::Query::PartitionedClauses
- Includes:
- Enumerable
- Defined in:
- lib/neo4j-core/query.rb
Instance Method Summary collapse
- #each ⇒ Object
- #generate_partitioning! ⇒ Object
-
#initialize(clauses) ⇒ PartitionedClauses
constructor
A new instance of PartitionedClauses.
Constructor Details
#initialize(clauses) ⇒ PartitionedClauses
Returns a new instance of PartitionedClauses.
428 429 430 431 |
# File 'lib/neo4j-core/query.rb', line 428 def initialize(clauses) @clauses = clauses @partitioning = [[]] end |
Instance Method Details
#each ⇒ Object
435 436 437 438 439 |
# File 'lib/neo4j-core/query.rb', line 435 def each generate_partitioning! @partitioning.each { |partition| yield partition } end |
#generate_partitioning! ⇒ Object
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/neo4j-core/query.rb', line 441 def generate_partitioning! @partitioning = [[]] @clauses.each do |clause| if clause.nil? && !fresh_partition? @partitioning << [] elsif clause_is_order_or_limit_directly_following_with_or_order?(clause) second_to_last << clause elsif clause_is_with_following_order_or_limit?(clause) second_to_last << clause second_to_last.sort_by! { |c| c.is_a?(::Neo4j::Core::QueryClauses::OrderClause) ? 1 : 0 } else @partitioning.last << clause end end end |