class ActiveRecord::QueryMethods::WithChain
WithChain
objects act as placeholder for queries in which with does not have any parameter. In this case, with must be chained with recursive
to return a new relation.
Public Class Methods
new(scope)
click to toggle source
# File lib/postgres_with/active_record/relation/query_methods.rb, line 6 def initialize(scope) @scope = scope end
Public Instance Methods
materialized(*args)
click to toggle source
# File lib/postgres_with/active_record/relation/query_methods.rb, line 10 def materialized(*args) materialized_args = args.flat_map do |arg| case arg when Hash name = arg.keys.first new_name = "_materialized_#{name}" { new_name => arg[name] } else arg end end @scope.with_values += materialized_args @scope end
recursive(*args)
click to toggle source
Returns a new relation expressing WITH RECURSIVE
# File lib/postgres_with/active_record/relation/query_methods.rb, line 26 def recursive(*args) @scope.with_values += args @scope.recursive_value = true @scope end