super 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Query
5
- class FormObject
6
- def initialize(model:, params:, namespace:, current_path:)
7
- @model = model
8
- @all_params = params.dup
9
- @namespace = namespace
10
- @params = params[namespace] || ActionController::Parameters.new
11
- @path = current_path
12
- @addons = {}
13
- end
14
-
15
- attr_reader :namespace
16
- attr_reader :path
17
- attr_reader :addons
18
-
19
- def add(klass, namespace:, **additional_initialization_arguments)
20
- instance = klass.new(
21
- model: @model,
22
- params: params_dig(namespace),
23
- **additional_initialization_arguments
24
- )
25
-
26
- addons[namespace] = instance
27
- end
28
-
29
- def apply_changes(records)
30
- addons.each_value do |addon|
31
- records = addon.apply_changes(records)
32
- end
33
-
34
- records
35
- end
36
-
37
- def to_partial_path
38
- "query"
39
- end
40
-
41
- private
42
-
43
- def params_dig(*keys)
44
- @params.dig(*keys) || ActionController::Parameters.new
45
- end
46
- end
47
- end
48
- end