pakyow-reflection 1.0.0.rc3 → 1.0.0.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pakyow/reflection/action.rb +4 -0
- data/lib/pakyow/reflection/behavior/reflecting.rb +7 -0
- data/lib/pakyow/reflection/builders/actions.rb +2 -2
- data/lib/pakyow/reflection/builders/{abstract.rb → base.rb} +1 -1
- data/lib/pakyow/reflection/builders/endpoints.rb +2 -2
- data/lib/pakyow/reflection/builders/source.rb +2 -2
- data/lib/pakyow/reflection/endpoint.rb +8 -0
- data/lib/pakyow/reflection/extensions/controller.rb +29 -18
- data/lib/pakyow/reflection/mirror.rb +21 -21
- data/lib/pakyow/reflection/scope.rb +4 -0
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 439c0fba540fdf1fc9b0fbd624c15ece95bc0a6df70061739b737b68bb91c125
|
4
|
+
data.tar.gz: 25b1a106b2b7afe76b4aa67ab9f6772a8dca937080885e4e91b0b14d66b4d9f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b1d83128091f06d7b141e90834c91b06d394e017a2ba862d06dfc71084ced0ecd45d7c488c85bc4c064dd3442d3351bf6903186eff03e3bbfbf916781a4b415
|
7
|
+
data.tar.gz: 5ad860dcc0bbe4a7980ab6acf1cfa971e4d22c62a2336574d1a121d424fe2366364daf777840dc3b8b697b73340591c0927a2e58989b56609fdba4a9c6623ca4
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "pakyow/reflection/builders/
|
3
|
+
require "pakyow/reflection/builders/base"
|
4
4
|
require "pakyow/reflection/builders/helpers/controller"
|
5
5
|
|
6
6
|
module Pakyow
|
7
7
|
module Reflection
|
8
8
|
module Builders
|
9
9
|
# @api private
|
10
|
-
class Actions <
|
10
|
+
class Actions < Base
|
11
11
|
include Helpers::Controller
|
12
12
|
|
13
13
|
def build(actions)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "pakyow/support/core_refinements/string/normalization"
|
4
4
|
|
5
|
-
require "pakyow/reflection/builders/
|
5
|
+
require "pakyow/reflection/builders/base"
|
6
6
|
require "pakyow/reflection/builders/helpers/controller"
|
7
7
|
require "pakyow/reflection/extensions/controller"
|
8
8
|
|
@@ -10,7 +10,7 @@ module Pakyow
|
|
10
10
|
module Reflection
|
11
11
|
module Builders
|
12
12
|
# @api private
|
13
|
-
class Endpoints <
|
13
|
+
class Endpoints < Base
|
14
14
|
include Helpers::Controller
|
15
15
|
|
16
16
|
using Support::Refinements::String::Normalization
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "pakyow/reflection/builders/
|
3
|
+
require "pakyow/reflection/builders/base"
|
4
4
|
|
5
5
|
module Pakyow
|
6
6
|
module Reflection
|
7
7
|
module Builders
|
8
8
|
# @api private
|
9
|
-
class Source <
|
9
|
+
class Source < Base
|
10
10
|
def build(scope)
|
11
11
|
(source_for_scope(scope) || define_source_for_scope(scope)).class_eval do
|
12
12
|
scope.attributes.each do |attribute|
|
@@ -19,6 +19,10 @@ module Pakyow
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def cleanup
|
23
|
+
@node = nil
|
24
|
+
end
|
25
|
+
|
22
26
|
private
|
23
27
|
|
24
28
|
def parse_dataset(dataset)
|
@@ -71,6 +75,10 @@ module Pakyow
|
|
71
75
|
def add_exposure(exposure)
|
72
76
|
@exposures << exposure
|
73
77
|
end
|
78
|
+
|
79
|
+
def cleanup
|
80
|
+
@exposures.each(&:cleanup)
|
81
|
+
end
|
74
82
|
end
|
75
83
|
end
|
76
84
|
end
|
@@ -76,27 +76,13 @@ module Pakyow
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
associations = data.send(
|
81
|
-
reflected_exposure.scope.plural_name
|
82
|
-
).source.class.associations.values.flatten
|
83
|
-
|
84
|
-
reflected_exposure.children.each do |nested_reflected_exposure|
|
85
|
-
association = associations.find { |possible_association|
|
86
|
-
possible_association.associated_source_name == nested_reflected_exposure.scope.plural_name
|
87
|
-
}
|
88
|
-
|
89
|
-
if association
|
90
|
-
query = query.including(association.name)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
79
|
+
query = apply_includes_to_query(query, reflected_exposure.scope.plural_name, reflected_exposure.children)
|
94
80
|
|
95
|
-
if reflects_specific_object?(reflected_exposure.scope.plural_name) && query.
|
81
|
+
if reflects_specific_object?(reflected_exposure.scope.plural_name) && query.count == 0
|
96
82
|
trigger 404
|
97
83
|
else
|
98
84
|
if !reflected_exposure.binding.to_s.include?("form") || reflected_endpoint.view_path.end_with?("/edit")
|
99
|
-
expose reflected_exposure.binding, query
|
85
|
+
expose reflected_exposure.binding.to_s, query
|
100
86
|
end
|
101
87
|
end
|
102
88
|
end
|
@@ -139,7 +125,9 @@ module Pakyow
|
|
139
125
|
# TODO: Handle cases where objects are associated by id but routed by another field.
|
140
126
|
# Implement when we allow foreign keys to be specified in associations.
|
141
127
|
#
|
142
|
-
|
128
|
+
if proxy.source.class.attributes.key?(self.class.parent.nested_param)
|
129
|
+
values[self.class.parent.nested_param] = params[self.class.parent.nested_param]
|
130
|
+
end
|
143
131
|
end
|
144
132
|
|
145
133
|
# Limit the action for update, delete.
|
@@ -277,6 +265,29 @@ module Pakyow
|
|
277
265
|
end
|
278
266
|
end
|
279
267
|
end
|
268
|
+
|
269
|
+
def apply_includes_to_query(query, plural_name, children)
|
270
|
+
associations = data.send(
|
271
|
+
plural_name
|
272
|
+
).source.class.associations.values.flatten
|
273
|
+
|
274
|
+
children.group_by { |child|
|
275
|
+
child.scope.plural_name
|
276
|
+
}.each do |nested_plural_name, child_exposures|
|
277
|
+
association = associations.find { |possible_association|
|
278
|
+
possible_association.associated_source_name == nested_plural_name
|
279
|
+
}
|
280
|
+
|
281
|
+
if association
|
282
|
+
context = self
|
283
|
+
query = query.including(association.name) {
|
284
|
+
context.__send__(:apply_includes_to_query, self, nested_plural_name, child_exposures.flat_map(&:children))
|
285
|
+
}
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
query
|
290
|
+
end
|
280
291
|
end
|
281
292
|
end
|
282
293
|
end
|
@@ -73,34 +73,32 @@ module Pakyow
|
|
73
73
|
view_path, view.info.dig(:reflection, :endpoint)
|
74
74
|
)
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
)
|
76
|
+
exposure = Exposure.new(
|
77
|
+
scope: scope,
|
78
|
+
node: binding_scope_node,
|
79
|
+
parent: parent_exposure,
|
80
|
+
binding: binding_scope_view.channeled_binding_name,
|
81
|
+
dataset: binding_scope_view.label(:dataset)
|
82
|
+
)
|
84
83
|
|
85
|
-
|
84
|
+
endpoint.add_exposure(exposure)
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
86
|
+
# Discover nested view scopes.
|
87
|
+
#
|
88
|
+
discover_view_scopes(
|
89
|
+
view_path: view_path,
|
90
|
+
view: binding_scope_view,
|
91
|
+
parent_scope: scope,
|
92
|
+
parent_exposure: exposure,
|
93
|
+
binding_path: binding_path.dup << binding_scope_node.label(:binding)
|
94
|
+
)
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
100
98
|
# Discover forms.
|
101
99
|
#
|
102
100
|
view.object.each_significant_node(:form) do |form_node|
|
103
|
-
if form_node.labeled?(:binding)
|
101
|
+
if form_node.labeled?(:binding) && !form_node.labeled?(:plug)
|
104
102
|
form_view = Presenter::View.from_object(form_node)
|
105
103
|
scope = scope_for_binding(form_view.binding_name, parent_scope)
|
106
104
|
|
@@ -172,13 +170,15 @@ module Pakyow
|
|
172
170
|
#
|
173
171
|
view.object.find_significant_nodes(:endpoint).select { |endpoint_node|
|
174
172
|
endpoint_node.label(:endpoint).to_s.end_with?("_delete")
|
173
|
+
}.reject { |endpoint_node|
|
174
|
+
endpoint_node.label(:endpoint).to_s.start_with?("@")
|
175
175
|
}.each do |endpoint_node|
|
176
176
|
scope = scope_for_binding(
|
177
177
|
endpoint_node.label(:endpoint).to_s.split("_", 2)[0],
|
178
178
|
parent_scope
|
179
179
|
)
|
180
180
|
|
181
|
-
|
181
|
+
if scope && endpoint_node.label(:endpoint).to_s == "#{scope.plural_name}_delete" && !scope.action(:delete)
|
182
182
|
scope.actions << Action.new(
|
183
183
|
name: :delete,
|
184
184
|
scope: scope,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakyow-reflection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pakyow-core
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0.
|
19
|
+
version: 1.0.0.rc4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0.
|
26
|
+
version: 1.0.0.rc4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pakyow-data
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.
|
33
|
+
version: 1.0.0.rc4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0.
|
40
|
+
version: 1.0.0.rc4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pakyow-form
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0.0.
|
47
|
+
version: 1.0.0.rc4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.0.
|
54
|
+
version: 1.0.0.rc4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pakyow-presenter
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.0.
|
61
|
+
version: 1.0.0.rc4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.0.
|
68
|
+
version: 1.0.0.rc4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pakyow-support
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.0.
|
75
|
+
version: 1.0.0.rc4
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0.
|
82
|
+
version: 1.0.0.rc4
|
83
83
|
description: Reflected behavior for Pakyow
|
84
84
|
email: bryan@metabahn.com
|
85
85
|
executables: []
|
@@ -95,8 +95,8 @@ files:
|
|
95
95
|
- lib/pakyow/reflection/behavior/config.rb
|
96
96
|
- lib/pakyow/reflection/behavior/reflecting.rb
|
97
97
|
- lib/pakyow/reflection/behavior/rendering/install_form_metadata.rb
|
98
|
-
- lib/pakyow/reflection/builders/abstract.rb
|
99
98
|
- lib/pakyow/reflection/builders/actions.rb
|
99
|
+
- lib/pakyow/reflection/builders/base.rb
|
100
100
|
- lib/pakyow/reflection/builders/endpoints.rb
|
101
101
|
- lib/pakyow/reflection/builders/helpers/controller.rb
|
102
102
|
- lib/pakyow/reflection/builders/source.rb
|