Class: ActiveRecordExtended::QueryMethods::WithCTE::WithChain
- Inherits:
-
Object
- Object
- ActiveRecordExtended::QueryMethods::WithCTE::WithChain
- Defined in:
- lib/active_record_extended/query_methods/with_cte.rb
Instance Method Summary collapse
-
#initialize(scope) ⇒ WithChain
constructor
A new instance of WithChain.
- #materialized(args) ⇒ Object
- #not_materialized(args) ⇒ Object
- #recursive(args) ⇒ Object
Constructor Details
#initialize(scope) ⇒ WithChain
Returns a new instance of WithChain.
82 83 84 85 |
# File 'lib/active_record_extended/query_methods/with_cte.rb', line 82 def initialize(scope) @scope = scope @scope.cte ||= WithCTE.new(scope) end |
Instance Method Details
#materialized(args) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/active_record_extended/query_methods/with_cte.rb', line 96 def materialized(args) @scope.tap do |scope| args.each_pair do |name, _expression| sym_name = name.to_sym raise ArgumentError.new("CTE already set as not_materialized") if scope.cte.not_materialized_key?(sym_name) scope.cte.materialized_keys << sym_name end scope.cte.pipe_cte_with!(args) end end |
#not_materialized(args) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/active_record_extended/query_methods/with_cte.rb', line 109 def not_materialized(args) @scope.tap do |scope| args.each_pair do |name, _expression| sym_name = name.to_sym raise ArgumentError.new("CTE already set as materialized") if scope.cte.materialized_key?(sym_name) scope.cte.not_materialized_keys << sym_name end scope.cte.pipe_cte_with!(args) end end |
#recursive(args) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/active_record_extended/query_methods/with_cte.rb', line 88 def recursive(args) @scope.tap do |scope| scope.recursive_value = true scope.cte.pipe_cte_with!(args) end end |