pakyow-reflection 1.0.0.rc5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/pakyow/application/behavior/reflection/reflecting.rb +54 -0
- data/lib/pakyow/{reflection/behavior/config.rb → application/config/reflection.rb} +6 -6
- data/lib/pakyow/presenter/renderer/behavior/reflection/install_form_metadata.rb +30 -0
- data/lib/pakyow/reflection/builders/source.rb +9 -1
- data/lib/pakyow/reflection/extensions/controller.rb +20 -0
- data/lib/pakyow/reflection/framework.rb +6 -6
- metadata +19 -19
- data/lib/pakyow/reflection/behavior/reflecting.rb +0 -52
- data/lib/pakyow/reflection/behavior/rendering/install_form_metadata.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6fdcf55904d4c98e4c2bbc5f5f3e16b2348e18d0740d4aff519adf174faccb6
|
4
|
+
data.tar.gz: 1a2fe4841022f58cee10db37a0e99e45b46134dd396815f4bd1605960e8d84ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad0da69c4fa726f1bce5aa213b745dc7aa807473d2aefb09ab847ad36c8e7c2bbea26ce68cbb5a3483134f9a530a379b9fcb3b16615224f4b2c2eeba6d3e992e
|
7
|
+
data.tar.gz: ef972e0e31525c60c7e6c43e68c4f35f08d6106a9cde13b9e423545dbfebd63585dc3acdddb677f0e1bfd838b90b1f9abe425f305e8f0b57b183be8f2ae18958
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pakyow/support/class_state"
|
4
|
+
|
5
|
+
require "pakyow/reflection/mirror"
|
6
|
+
|
7
|
+
module Pakyow
|
8
|
+
class Application
|
9
|
+
module Behavior
|
10
|
+
module Reflection
|
11
|
+
module Reflecting
|
12
|
+
extend Support::Extension
|
13
|
+
|
14
|
+
apply_extension do
|
15
|
+
attr_reader :mirror
|
16
|
+
|
17
|
+
after "initialize", priority: :high do
|
18
|
+
@mirror = Pakyow::Reflection::Mirror.new(self)
|
19
|
+
|
20
|
+
builders = Hash[
|
21
|
+
config.reflection.builders.map { |type, builder|
|
22
|
+
[type, builder.new(self, @mirror.scopes)]
|
23
|
+
}
|
24
|
+
]
|
25
|
+
|
26
|
+
# Build the scopes.
|
27
|
+
#
|
28
|
+
@mirror.scopes.each do |scope|
|
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)
|
41
|
+
|
42
|
+
# Cleanup.
|
43
|
+
#
|
44
|
+
unless Pakyow.env?(:test)
|
45
|
+
@mirror.scopes.each(&:cleanup)
|
46
|
+
@mirror.endpoints.each(&:cleanup)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -7,17 +7,17 @@ require "pakyow/reflection/builders/endpoints"
|
|
7
7
|
require "pakyow/reflection/builders/actions"
|
8
8
|
|
9
9
|
module Pakyow
|
10
|
-
|
11
|
-
module
|
12
|
-
module
|
10
|
+
class Application
|
11
|
+
module Config
|
12
|
+
module Reflection
|
13
13
|
extend Support::Extension
|
14
14
|
|
15
15
|
apply_extension do
|
16
16
|
configurable :reflection do
|
17
17
|
setting :builders, {
|
18
|
-
source: Builders::Source,
|
19
|
-
endpoints: Builders::Endpoints,
|
20
|
-
actions: Builders::Actions
|
18
|
+
source: Pakyow::Reflection::Builders::Source,
|
19
|
+
endpoints: Pakyow::Reflection::Builders::Endpoints,
|
20
|
+
actions: Pakyow::Reflection::Builders::Actions
|
21
21
|
}
|
22
22
|
|
23
23
|
setting :ignored_template_stores, [:errors]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pakyow/support/extension"
|
4
|
+
|
5
|
+
module Pakyow
|
6
|
+
module Presenter
|
7
|
+
class Renderer
|
8
|
+
module Behavior
|
9
|
+
module Reflection
|
10
|
+
module InstallFormMetadata
|
11
|
+
extend Support::Extension
|
12
|
+
|
13
|
+
apply_extension do
|
14
|
+
build do |view, composer:|
|
15
|
+
forms = view.forms
|
16
|
+
if !view.object.is_a?(StringDoc) && view.object.significant?(:form)
|
17
|
+
forms << view
|
18
|
+
end
|
19
|
+
|
20
|
+
forms.each do |form|
|
21
|
+
form.label(:form)[:view_path] = composer.view_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -8,7 +8,7 @@ module Pakyow
|
|
8
8
|
# @api private
|
9
9
|
class Source < Base
|
10
10
|
def build(scope)
|
11
|
-
|
11
|
+
block = Proc.new do
|
12
12
|
scope.attributes.each do |attribute|
|
13
13
|
unless attributes.key?(attribute.name)
|
14
14
|
attribute attribute.name, attribute.type
|
@@ -25,6 +25,14 @@ module Pakyow
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
(source_for_scope(scope) || define_source_for_scope(scope)).tap do |source|
|
30
|
+
unless source.__source_location
|
31
|
+
source.__source_location = block.source_location
|
32
|
+
end
|
33
|
+
|
34
|
+
source.class_eval(&block)
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
38
|
private
|
@@ -82,6 +82,10 @@ module Pakyow
|
|
82
82
|
trigger 404
|
83
83
|
else
|
84
84
|
if !reflected_exposure.binding.to_s.include?("form") || reflected_endpoint.view_path.end_with?("/edit")
|
85
|
+
logger.debug {
|
86
|
+
"[reflection] exposing dataset for `#{reflected_exposure.binding}': #{query.inspect}"
|
87
|
+
}
|
88
|
+
|
85
89
|
expose reflected_exposure.binding.to_s, query
|
86
90
|
end
|
87
91
|
end
|
@@ -108,11 +112,19 @@ module Pakyow
|
|
108
112
|
local.__send__(:verify_nested_data, reflected_action.nested, self)
|
109
113
|
end
|
110
114
|
end
|
115
|
+
|
116
|
+
logger.debug {
|
117
|
+
"[reflection] verified and validated submitted values for `#{reflected_action.scope.name}'"
|
118
|
+
}
|
111
119
|
end
|
112
120
|
end
|
113
121
|
|
114
122
|
def perform_reflected_action
|
115
123
|
with_reflected_action do |reflected_action|
|
124
|
+
logger.debug {
|
125
|
+
"[reflection] performing `#{[self.class.name_of_self, connection.values[:__endpoint_name]].join("_")}' for `#{reflected_action.view_path}'"
|
126
|
+
}
|
127
|
+
|
116
128
|
proxy = data.public_send(reflected_action.scope.plural_name)
|
117
129
|
|
118
130
|
# Pull initial values from the params.
|
@@ -146,6 +158,10 @@ module Pakyow
|
|
146
158
|
connection.get(:__endpoint_name), values
|
147
159
|
)
|
148
160
|
end
|
161
|
+
|
162
|
+
logger.debug {
|
163
|
+
"[reflection] changes have been saved to the `#{proxy.source.class.plural_name}' data source"
|
164
|
+
}
|
149
165
|
end
|
150
166
|
rescue Data::ConstraintViolation
|
151
167
|
trigger 404
|
@@ -153,6 +169,10 @@ module Pakyow
|
|
153
169
|
|
154
170
|
def redirect_to_reflected_destination
|
155
171
|
if destination = reflected_destination
|
172
|
+
logger.debug {
|
173
|
+
"[reflection] redirecting to `#{destination}'"
|
174
|
+
}
|
175
|
+
|
156
176
|
redirect destination
|
157
177
|
end
|
158
178
|
end
|
@@ -3,20 +3,20 @@
|
|
3
3
|
require "pakyow/framework"
|
4
4
|
require "pakyow/support/inflector"
|
5
5
|
|
6
|
-
require "pakyow/
|
7
|
-
require "pakyow/
|
8
|
-
require "pakyow/
|
6
|
+
require "pakyow/application/config/reflection"
|
7
|
+
require "pakyow/application/behavior/reflection/reflecting"
|
8
|
+
require "pakyow/presenter/renderer/behavior/reflection/install_form_metadata"
|
9
9
|
require "pakyow/reflection/mirror"
|
10
10
|
|
11
11
|
module Pakyow
|
12
12
|
module Reflection
|
13
13
|
class Framework < Pakyow::Framework(:reflection)
|
14
14
|
def boot
|
15
|
-
object.include
|
16
|
-
object.include Behavior::Reflecting
|
15
|
+
object.include Application::Config::Reflection
|
16
|
+
object.include Application::Behavior::Reflection::Reflecting
|
17
17
|
|
18
18
|
object.isolated :Renderer do
|
19
|
-
include Behavior::
|
19
|
+
include Presenter::Renderer::Behavior::Reflection::InstallFormMetadata
|
20
20
|
end
|
21
21
|
|
22
22
|
object.isolated :Controller do
|
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
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pakyow-core
|
@@ -16,72 +16,72 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0
|
19
|
+
version: 1.0.0
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
83
83
|
description: Reflected behavior for Pakyow
|
84
|
-
email: bryan@
|
84
|
+
email: bryan@bryanp.org
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
@@ -89,12 +89,12 @@ files:
|
|
89
89
|
- CHANGELOG.md
|
90
90
|
- LICENSE
|
91
91
|
- README.md
|
92
|
+
- lib/pakyow/application/behavior/reflection/reflecting.rb
|
93
|
+
- lib/pakyow/application/config/reflection.rb
|
94
|
+
- lib/pakyow/presenter/renderer/behavior/reflection/install_form_metadata.rb
|
92
95
|
- lib/pakyow/reflection.rb
|
93
96
|
- lib/pakyow/reflection/action.rb
|
94
97
|
- lib/pakyow/reflection/attribute.rb
|
95
|
-
- lib/pakyow/reflection/behavior/config.rb
|
96
|
-
- lib/pakyow/reflection/behavior/reflecting.rb
|
97
|
-
- lib/pakyow/reflection/behavior/rendering/install_form_metadata.rb
|
98
98
|
- lib/pakyow/reflection/builders/actions.rb
|
99
99
|
- lib/pakyow/reflection/builders/base.rb
|
100
100
|
- lib/pakyow/reflection/builders/endpoints.rb
|
@@ -106,7 +106,7 @@ files:
|
|
106
106
|
- lib/pakyow/reflection/mirror.rb
|
107
107
|
- lib/pakyow/reflection/nested.rb
|
108
108
|
- lib/pakyow/reflection/scope.rb
|
109
|
-
homepage: https://pakyow.
|
109
|
+
homepage: https://pakyow.com
|
110
110
|
licenses:
|
111
111
|
- LGPL-3.0
|
112
112
|
metadata: {}
|
@@ -121,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: 2.5.0
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - "
|
124
|
+
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
126
|
+
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubygems_version: 3.0.3
|
129
129
|
signing_key:
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pakyow/support/class_state"
|
4
|
-
|
5
|
-
require "pakyow/reflection/mirror"
|
6
|
-
|
7
|
-
module Pakyow
|
8
|
-
module Reflection
|
9
|
-
module Behavior
|
10
|
-
module Reflecting
|
11
|
-
extend Support::Extension
|
12
|
-
|
13
|
-
apply_extension do
|
14
|
-
attr_reader :mirror
|
15
|
-
|
16
|
-
after "initialize", priority: :high do
|
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)
|
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)
|
40
|
-
|
41
|
-
# Cleanup.
|
42
|
-
#
|
43
|
-
unless Pakyow.env?(:test)
|
44
|
-
@mirror.scopes.each(&:cleanup)
|
45
|
-
@mirror.endpoints.each(&:cleanup)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pakyow/support/extension"
|
4
|
-
|
5
|
-
module Pakyow
|
6
|
-
module Reflection
|
7
|
-
module Behavior
|
8
|
-
module Rendering
|
9
|
-
module InstallFormMetadata
|
10
|
-
extend Support::Extension
|
11
|
-
|
12
|
-
apply_extension do
|
13
|
-
build do |view, composer:|
|
14
|
-
forms = view.forms
|
15
|
-
if !view.object.is_a?(StringDoc) && view.object.significant?(:form)
|
16
|
-
forms << view
|
17
|
-
end
|
18
|
-
|
19
|
-
forms.each do |form|
|
20
|
-
form.label(:form)[:view_path] = composer.view_path
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|