pakyow-reflection 1.0.0.rc2 → 1.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pakyow/reflection/action.rb +1 -0
- data/lib/pakyow/reflection/attribute.rb +1 -0
- data/lib/pakyow/reflection/behavior/reflecting.rb +22 -24
- data/lib/pakyow/reflection/builders/actions.rb +1 -0
- data/lib/pakyow/reflection/builders/endpoints.rb +1 -0
- data/lib/pakyow/reflection/builders/helpers/controller.rb +1 -1
- data/lib/pakyow/reflection/builders/source.rb +1 -0
- data/lib/pakyow/reflection/endpoint.rb +2 -0
- data/lib/pakyow/reflection/extensions/controller.rb +23 -42
- data/lib/pakyow/reflection/framework.rb +4 -7
- data/lib/pakyow/reflection/mirror.rb +2 -1
- data/lib/pakyow/reflection/nested.rb +1 -0
- data/lib/pakyow/reflection/scope.rb +1 -0
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e9031c45360015c7b068ad6f85938902ac14f3cb5cb0e4d55ca4999c81d0e99
|
4
|
+
data.tar.gz: 262f93fbf4fea38139806e6fd917cd85c134e5a287151121a091fd3f4e981ec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 440f1e6a0e2076a0f1e01bbb1f892cf36ffa94668fb110b7653ddcfc32de2f7404587242445c4ac13f69cbef254ab7e7cd4e0db972afcf13b334db88606f2c54
|
7
|
+
data.tar.gz: dc888c10a53b00cf2c61e6842d272f053b905c33e190fe692191a5987f6415d8c7e1d5f47eebbd1e1eb1f8de4cd9d1b07da63ef41d1d2fc521d6f95e8383dcf7
|
@@ -14,31 +14,29 @@ module Pakyow
|
|
14
14
|
attr_reader :mirror
|
15
15
|
|
16
16
|
after "initialize", priority: :high do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
builders
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
builders[:source].build(scope)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Build the actions.
|
33
|
-
#
|
34
|
-
@mirror.scopes.each do |scope|
|
35
|
-
builders[:actions].build(scope.actions)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Build the endpoints.
|
39
|
-
#
|
40
|
-
builders[:endpoints].build(@mirror.endpoints)
|
17
|
+
@mirror = Mirror.new(self)
|
18
|
+
|
19
|
+
builders = Hash[
|
20
|
+
config.reflection.builders.map { |type, builder|
|
21
|
+
[type, builder.new(self, @mirror.scopes)]
|
22
|
+
}
|
23
|
+
]
|
24
|
+
|
25
|
+
# Build the scopes.
|
26
|
+
#
|
27
|
+
@mirror.scopes.each do |scope|
|
28
|
+
builders[:source].build(scope)
|
41
29
|
end
|
30
|
+
|
31
|
+
# Build the actions.
|
32
|
+
#
|
33
|
+
@mirror.scopes.each do |scope|
|
34
|
+
builders[:actions].build(scope.actions)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Build the endpoints.
|
38
|
+
#
|
39
|
+
builders[:endpoints].build(@mirror.endpoints)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
@@ -57,7 +57,7 @@ module Pakyow
|
|
57
57
|
String.normalize_path(path)[1..-1].gsub("/", "_").to_sym
|
58
58
|
end
|
59
59
|
|
60
|
-
method = if context.is_a?(Class) && context.ancestors.include?(Pakyow::Controller)
|
60
|
+
method = if context.is_a?(Class) && context.ancestors.include?(Pakyow::Routing::Controller)
|
61
61
|
:namespace
|
62
62
|
else
|
63
63
|
:controller
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Pakyow
|
4
4
|
module Reflection
|
5
|
+
# @api private
|
5
6
|
class Exposure
|
6
7
|
attr_reader :scope, :node, :binding, :dataset, :parent, :children
|
7
8
|
|
@@ -53,6 +54,7 @@ module Pakyow
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
# @api private
|
56
58
|
class Endpoint
|
57
59
|
attr_reader :view_path, :options, :exposures
|
58
60
|
|
@@ -28,26 +28,6 @@ module Pakyow
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def reflected_scope
|
32
|
-
connection.get(:__reflected_scope)
|
33
|
-
end
|
34
|
-
|
35
|
-
def reflected_action
|
36
|
-
connection.get(:__reflected_action)
|
37
|
-
end
|
38
|
-
|
39
|
-
def reflected_endpoint
|
40
|
-
connection.get(:__reflected_endpoint)
|
41
|
-
end
|
42
|
-
|
43
|
-
def reflects_specific_object?(object_name)
|
44
|
-
(
|
45
|
-
self.class.__object_name.name == object_name && (
|
46
|
-
connection.get(:__endpoint_name) == :show || connection.get(:__endpoint_name) == :edit
|
47
|
-
)
|
48
|
-
) || parent_resource_named?(object_name)
|
49
|
-
end
|
50
|
-
|
51
31
|
def reflective_expose
|
52
32
|
reflected_endpoint.exposures.each do |reflected_exposure|
|
53
33
|
if reflected_exposure.parent.nil? || reflected_exposure.binding.to_s.include?("form")
|
@@ -123,22 +103,7 @@ module Pakyow
|
|
123
103
|
end
|
124
104
|
end
|
125
105
|
|
126
|
-
def
|
127
|
-
logger.debug "[reflection] create"
|
128
|
-
handle_submitted_data
|
129
|
-
end
|
130
|
-
|
131
|
-
def reflective_update
|
132
|
-
logger.debug "[reflection] update"
|
133
|
-
handle_submitted_data
|
134
|
-
end
|
135
|
-
|
136
|
-
def reflective_delete
|
137
|
-
logger.debug "[reflection] delete"
|
138
|
-
handle_submitted_data
|
139
|
-
end
|
140
|
-
|
141
|
-
def verify_submitted_form
|
106
|
+
def verify_reflected_form
|
142
107
|
with_reflected_action do |reflected_action|
|
143
108
|
local = self
|
144
109
|
|
@@ -160,7 +125,7 @@ module Pakyow
|
|
160
125
|
end
|
161
126
|
end
|
162
127
|
|
163
|
-
def
|
128
|
+
def perform_reflected_action
|
164
129
|
with_reflected_action do |reflected_action|
|
165
130
|
proxy = data.public_send(reflected_action.scope.plural_name)
|
166
131
|
|
@@ -207,11 +172,11 @@ module Pakyow
|
|
207
172
|
def reflected_destination
|
208
173
|
with_reflected_action do |reflected_action|
|
209
174
|
if connection.form && origin = connection.form[:origin]
|
210
|
-
if instance_variable_defined?(:@object)
|
211
|
-
if self.class.routes[:get].
|
212
|
-
|
213
|
-
elsif self.class.routes[:get].
|
214
|
-
|
175
|
+
if instance_variable_defined?(:@object)
|
176
|
+
if route = self.class.routes[:get].find { |route| route.name == :show }
|
177
|
+
route.build_path(self.class.path_to_self, params.merge(@object.one.to_h))
|
178
|
+
elsif route = self.class.routes[:get].find { |route| route.name == :list }
|
179
|
+
route.build_path(self.class.path_to_self, params)
|
215
180
|
else
|
216
181
|
origin
|
217
182
|
end
|
@@ -226,6 +191,22 @@ module Pakyow
|
|
226
191
|
|
227
192
|
private
|
228
193
|
|
194
|
+
def reflected_action
|
195
|
+
connection.get(:__reflected_action)
|
196
|
+
end
|
197
|
+
|
198
|
+
def reflected_endpoint
|
199
|
+
connection.get(:__reflected_endpoint)
|
200
|
+
end
|
201
|
+
|
202
|
+
def reflects_specific_object?(object_name)
|
203
|
+
(
|
204
|
+
self.class.__object_name.name == object_name && (
|
205
|
+
connection.get(:__endpoint_name) == :show || connection.get(:__endpoint_name) == :edit
|
206
|
+
)
|
207
|
+
) || parent_resource_named?(object_name)
|
208
|
+
end
|
209
|
+
|
229
210
|
def parent_resource_named?(object_name, context = self.class)
|
230
211
|
if context && context.parent
|
231
212
|
context.parent.__object_name&.name == object_name || parent_resource_named?(object_name, context.parent)
|
@@ -31,7 +31,7 @@ module Pakyow
|
|
31
31
|
if (reflected_action = controller.connection.get(:__reflected_action)) && reflected_action.name == controller.connection.get(:__endpoint_name)
|
32
32
|
case reflected_action.name
|
33
33
|
when :create, :update
|
34
|
-
controller.
|
34
|
+
controller.verify_reflected_form
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -39,12 +39,9 @@ module Pakyow
|
|
39
39
|
action :perform do
|
40
40
|
if (reflected_action = controller.connection.get(:__reflected_action)) && reflected_action.name == controller.connection.get(:__endpoint_name)
|
41
41
|
case reflected_action.name
|
42
|
-
when :create
|
43
|
-
controller.
|
44
|
-
|
45
|
-
controller.reflective_update
|
46
|
-
when :delete
|
47
|
-
controller.reflective_delete
|
42
|
+
when :create, :update, :delete
|
43
|
+
controller.perform_reflected_action
|
44
|
+
@object = controller.instance_variable_get(:@object)
|
48
45
|
end
|
49
46
|
end
|
50
47
|
end
|
@@ -14,6 +14,7 @@ module Pakyow
|
|
14
14
|
module Reflection
|
15
15
|
# Reflects state from an application's view templates.
|
16
16
|
#
|
17
|
+
# @api private
|
17
18
|
class Mirror
|
18
19
|
using Support::DeepDup
|
19
20
|
|
@@ -235,7 +236,7 @@ module Pakyow
|
|
235
236
|
view.binding_props.reject { |binding_prop_node|
|
236
237
|
binding_prop_node.significant?(:multipart_binding) && binding_prop_node.label(:binding) != view.binding_name
|
237
238
|
}.select { |binding_prop_node|
|
238
|
-
!fields || Presenter::Form::FIELD_TAGS.include?(binding_prop_node.tagname)
|
239
|
+
!fields || Presenter::Views::Form::FIELD_TAGS.include?(binding_prop_node.tagname)
|
239
240
|
}.each_with_object([]) do |binding_prop_node, attributes|
|
240
241
|
binding_prop_view = Presenter::View.from_object(binding_prop_node)
|
241
242
|
binding_prop_name = if binding_prop_node.significant?(:multipart_binding)
|
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.rc3
|
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-09 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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
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.rc3
|
83
83
|
description: Reflected behavior for Pakyow
|
84
84
|
email: bryan@metabahn.com
|
85
85
|
executables: []
|