interfacets 0.9.99 → 0.99999
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/LICENSE +9 -17
- data/lib/interfacets/client/actor.rb +2 -1
- data/lib/interfacets/client/assets.rb +77 -64
- data/lib/interfacets/client/bus.rb +28 -9
- data/lib/interfacets/client/channels/api.rb +138 -39
- data/lib/interfacets/client/channels/audio.rb +13 -10
- data/lib/interfacets/client/channels/base.rb +2 -2
- data/lib/interfacets/client/channels/pubsub.rb +69 -0
- data/lib/interfacets/client/channels/react/builder.rb +42 -72
- data/lib/interfacets/client/channels/react/channel.rb +7 -5
- data/lib/interfacets/client/channels/react/evaluator.rb +6 -4
- data/lib/interfacets/client/channels/timer.rb +8 -7
- data/lib/interfacets/client/channels/url.rb +39 -6
- data/lib/interfacets/client/registry.rb +3 -2
- data/lib/interfacets/client/slots.rb +45 -0
- data/lib/interfacets/client/system.rb +20 -15
- data/lib/interfacets/client/template.rb +90 -0
- data/lib/interfacets/client/utils/mruby_patches.rb +7 -3
- data/lib/interfacets/client/utils/open_struct.rb +2 -4
- data/lib/interfacets/component_registry.rb +34 -29
- data/lib/interfacets/component_schema_parser.rb +8 -4
- data/lib/interfacets/mruby/build_config.rb +8 -4
- data/lib/interfacets/mruby/entrypoint.rb +2 -2
- data/lib/interfacets/server/api.rb +44 -7
- data/lib/interfacets/server/assets.rb +58 -23
- data/lib/interfacets/server/basic_router.rb +29 -19
- data/lib/interfacets/server/bus.rb +5 -6
- data/lib/interfacets/server/registry.rb +17 -10
- data/lib/interfacets/shared/basic_routable.rb +7 -4
- data/lib/interfacets/shared/entities/bus.rb +619 -185
- data/lib/interfacets/shared/entities/changeset.rb +432 -0
- data/lib/interfacets/shared/entities/collection_proxy.rb +132 -72
- data/lib/interfacets/shared/entities/specs/handlers.rb +58 -37
- data/lib/interfacets/shared/entities/specs.rb +184 -18
- data/lib/interfacets/shared/entity.rb +113 -23
- data/lib/interfacets/shared/entity_dsl.rb +138 -20
- data/lib/interfacets/shared/facet.rb +128 -68
- data/lib/interfacets/shared/generated_store.rb +69 -34
- data/lib/interfacets/shared/refreshable.rb +85 -0
- data/lib/interfacets/shared/utils.rb +36 -32
- data/lib/interfacets/shared/validations.rb +746 -26
- data/lib/interfacets/shared/view.rb +74 -28
- data/lib/interfacets/test/component_registry.rb +31 -12
- data/lib/interfacets/test/js/inline_bus.rb +51 -25
- data/lib/interfacets/test/js/nodo_bus.rb +21 -10
- data/lib/interfacets/test/js/receivers/api.rb +14 -12
- data/lib/interfacets/test/js/receivers/audio.rb +61 -0
- data/lib/interfacets/test/js/receivers/pubsub.rb +50 -0
- data/lib/interfacets/test/js/receivers/react/node/xml_parser.rb +33 -5
- data/lib/interfacets/test/js/receivers/react/node.rb +69 -15
- data/lib/interfacets/test/js/receivers/react.rb +13 -4
- data/lib/interfacets/test/js/receivers/timer.rb +12 -8
- data/lib/interfacets/test/js/receivers/url.rb +47 -11
- data/lib/interfacets/test/ui_simulator.rb +88 -18
- data/lib/interfacets/test/validation_engine.rb +82 -49
- data/lib/interfacets/test.rb +1 -3
- data/lib/interfacets/version.rb +1 -1
- data/lib/interfacets.rb +11 -3
- metadata +31 -28
- data/.rubocop.yml +0 -180
- data/.tmp +0 -5
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -14
- data/lib/interfacets/client/channels/page_visibility.rb +0 -21
- data/lib/interfacets/client/channels/react/dom.rb +0 -91
- data/lib/interfacets/client/channels/speech_to_text.rb +0 -100
- data/lib/interfacets/client/config.rb +0 -22
- data/lib/interfacets/client/delegator.rb +0 -37
- data/lib/interfacets/server/assets/facet.rb +0 -63
- data/lib/interfacets/server/config.rb +0 -87
- data/lib/interfacets/server/facets/deserializer.rb +0 -25
- data/lib/interfacets/server/facets/schema/serializer.rb +0 -54
- data/lib/interfacets/server/facets/serializer.rb +0 -50
|
@@ -3,7 +3,17 @@
|
|
|
3
3
|
module Interfacets
|
|
4
4
|
module Shared
|
|
5
5
|
module EntityDsl
|
|
6
|
-
extend
|
|
6
|
+
extend(ActiveSupport::Concern)
|
|
7
|
+
|
|
8
|
+
# Instance methods the framework calls on every entity. Declaring an accessor,
|
|
9
|
+
# association or action with one of these names would silently replace the
|
|
10
|
+
# method and break the bus (e.g. `accessor(:store)`), so the DSL rejects them.
|
|
11
|
+
RESERVED_NAMES = %w[
|
|
12
|
+
store parent changeset changed? checkpoint! revert! record entity_role root invalidate!
|
|
13
|
+
entity_nesting entity_at association on_build
|
|
14
|
+
errors touched? touch! untouched! submitted? submitted! reset_submission!
|
|
15
|
+
errors_if_changed valid? validate validated_children merge_record_errors
|
|
16
|
+
]
|
|
7
17
|
|
|
8
18
|
included do |base|
|
|
9
19
|
if base.respond_to?(:inherit_attributes)
|
|
@@ -12,13 +22,13 @@ module Interfacets
|
|
|
12
22
|
end
|
|
13
23
|
|
|
14
24
|
class_methods do
|
|
15
|
-
attr_accessor
|
|
25
|
+
attr_accessor(:manifest)
|
|
16
26
|
|
|
17
|
-
def
|
|
27
|
+
def entity_role(name = nil)
|
|
18
28
|
if name
|
|
19
|
-
@
|
|
29
|
+
@entity_role = name.to_s
|
|
20
30
|
else
|
|
21
|
-
@
|
|
31
|
+
@entity_role
|
|
22
32
|
end
|
|
23
33
|
end
|
|
24
34
|
|
|
@@ -26,8 +36,9 @@ module Interfacets
|
|
|
26
36
|
{
|
|
27
37
|
accessors:,
|
|
28
38
|
actions:,
|
|
39
|
+
after_hooks:,
|
|
29
40
|
mergers:,
|
|
30
|
-
|
|
41
|
+
entity_role: @entity_role,
|
|
31
42
|
associations:,
|
|
32
43
|
validators:
|
|
33
44
|
}
|
|
@@ -38,8 +49,15 @@ module Interfacets
|
|
|
38
49
|
attrs = parent.inheritable_attributes
|
|
39
50
|
@accessors = attrs[:accessors].dup.merge(accessors)
|
|
40
51
|
@actions = attrs[:actions].dup.merge(actions)
|
|
52
|
+
@after_hooks = (
|
|
53
|
+
attrs[:after_hooks]
|
|
54
|
+
.to_h { |k, v|
|
|
55
|
+
[k, v.dup]
|
|
56
|
+
}
|
|
57
|
+
.merge(after_hooks) { |_, inherited, own| inherited + own }
|
|
58
|
+
)
|
|
41
59
|
@mergers = attrs[:mergers].dup.merge(mergers)
|
|
42
|
-
@
|
|
60
|
+
@entity_role ||= attrs[:entity_role]
|
|
43
61
|
|
|
44
62
|
attrs[:associations].each do |name, spec|
|
|
45
63
|
associations[name] ||= spec.dup_for(self)
|
|
@@ -48,7 +66,10 @@ module Interfacets
|
|
|
48
66
|
@validators = (attrs[:validators].dup + validators).uniq
|
|
49
67
|
end
|
|
50
68
|
|
|
51
|
-
|
|
69
|
+
# `merge(attr, :save)` applies to the request, `merge(attr, :save, reply: true)`
|
|
70
|
+
# to the reply to that request, `merge(attr, :reply)` to every reply,
|
|
71
|
+
# `merge(attr, :patch)` to every patch-like event.
|
|
72
|
+
def merge(name, *events, reply: false, &block)
|
|
52
73
|
spec = Entities::Specs::Merger.new(
|
|
53
74
|
name:,
|
|
54
75
|
block:
|
|
@@ -58,28 +79,69 @@ module Interfacets
|
|
|
58
79
|
|
|
59
80
|
if events.empty?
|
|
60
81
|
target[:default] = spec
|
|
82
|
+
target["default"] = spec
|
|
61
83
|
else
|
|
62
84
|
events.each do |event|
|
|
63
|
-
|
|
85
|
+
key = reply ? "reply:#{event}" : event.to_s
|
|
86
|
+
target[key.to_sym] = spec
|
|
87
|
+
target[key] = spec
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def protect_during_patch(*attribute_names)
|
|
93
|
+
attribute_names.each do |attr_name|
|
|
94
|
+
merge(attr_name, :patch) do |entity, server_val|
|
|
95
|
+
entity.send("#{attr_name}=", server_val) unless entity.changed?(attr_name)
|
|
64
96
|
end
|
|
65
97
|
end
|
|
66
98
|
end
|
|
67
99
|
|
|
100
|
+
def reject_reserved_name!(name, kind)
|
|
101
|
+
return unless RESERVED_NAMES.include?(name.to_s)
|
|
102
|
+
|
|
103
|
+
raise(
|
|
104
|
+
ArgumentError.new(
|
|
105
|
+
"#{kind} name '#{name}' is reserved: it is an Interfacets::Shared::Entity method " \
|
|
106
|
+
"(reserved names: #{RESERVED_NAMES.join(", ")})"
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
|
|
68
111
|
def accessor(
|
|
69
112
|
name,
|
|
70
|
-
getter:
|
|
71
|
-
setter:
|
|
113
|
+
getter: nil,
|
|
114
|
+
setter: nil,
|
|
72
115
|
accepted_by: Entities::Specs::ANY
|
|
73
116
|
)
|
|
74
117
|
name = name.to_s
|
|
118
|
+
reject_reserved_name!(name, "Accessor")
|
|
75
119
|
accessors[name] = Entities::Specs::Accessor.new(name:, accepted_by:)
|
|
76
120
|
|
|
121
|
+
setter ||= ->(val) {
|
|
122
|
+
if store.respond_to?("#{name}=")
|
|
123
|
+
store.send("#{name}=", val)
|
|
124
|
+
else
|
|
125
|
+
instance_variable_set("@#{name}", val)
|
|
126
|
+
end
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getter ||= -> {
|
|
130
|
+
if store.respond_to?(name)
|
|
131
|
+
store.send(name)
|
|
132
|
+
elsif instance_variable_defined?("@#{name}")
|
|
133
|
+
instance_variable_get("@#{name}")
|
|
134
|
+
end
|
|
135
|
+
}
|
|
136
|
+
|
|
77
137
|
define_method(name, &getter)
|
|
78
138
|
define_method("#{name}=", &setter)
|
|
79
139
|
end
|
|
80
140
|
|
|
141
|
+
# rubocop:disable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
81
142
|
def association(name, mod = nil, **spec_params, &block)
|
|
82
143
|
name = name.to_s
|
|
144
|
+
reject_reserved_name!(name, "Association")
|
|
83
145
|
associations[name] ||= Entities::Specs::Association.new(parent: self, name: name)
|
|
84
146
|
associations[name].apply(mod:, **spec_params, &block)
|
|
85
147
|
|
|
@@ -91,27 +153,83 @@ module Interfacets
|
|
|
91
153
|
association(name).set(val)
|
|
92
154
|
end
|
|
93
155
|
end
|
|
156
|
+
# rubocop:enable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
94
157
|
|
|
95
|
-
|
|
96
|
-
|
|
158
|
+
# rubocop:disable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
159
|
+
def reference(*args, **opts, &block)
|
|
160
|
+
association(
|
|
161
|
+
*args,
|
|
162
|
+
**opts, type: :reference,
|
|
163
|
+
&block
|
|
164
|
+
)
|
|
97
165
|
end
|
|
166
|
+
# rubocop:enable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
98
167
|
|
|
99
|
-
|
|
100
|
-
|
|
168
|
+
# rubocop:disable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
169
|
+
def collection(*args, **opts, &block)
|
|
170
|
+
association(
|
|
171
|
+
*args,
|
|
172
|
+
**opts, type: :collection,
|
|
173
|
+
&block
|
|
174
|
+
)
|
|
101
175
|
end
|
|
176
|
+
# rubocop:enable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
102
177
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
178
|
+
# Declares an action the client asks the server to run. The server
|
|
179
|
+
# answers with an event of the same action carrying `in_reply_to`.
|
|
180
|
+
# `reply:` holds options for that reply (`reply: { patch: true }` merges
|
|
181
|
+
# it as a patch). Run code when the reply arrives with
|
|
182
|
+
# `after(:name) { ... }`.
|
|
183
|
+
def server_action(name, only_if_valid: true, invalidates: nil, stateless: false, reply: {})
|
|
184
|
+
action(
|
|
185
|
+
name,
|
|
186
|
+
accepted_by: :server,
|
|
187
|
+
only_if_valid:,
|
|
188
|
+
invalidates:,
|
|
189
|
+
stateless:,
|
|
190
|
+
reply_accepted_by: :client,
|
|
191
|
+
reply_patch: reply.fetch(:patch, false)
|
|
192
|
+
)
|
|
106
193
|
|
|
107
194
|
define_method(name) do
|
|
108
195
|
store.send(name, entity: self)
|
|
109
196
|
end
|
|
110
197
|
end
|
|
111
198
|
|
|
112
|
-
|
|
199
|
+
# Runs the block (instance_exec'd on the entity) when the server's
|
|
200
|
+
# reply to the server action `name` arrives. Blocks stack in
|
|
201
|
+
# definition order.
|
|
202
|
+
def after(name, &block)
|
|
203
|
+
name = name.to_s
|
|
204
|
+
unless actions[name]&.replies?
|
|
205
|
+
raise(
|
|
206
|
+
ArgumentError.new(
|
|
207
|
+
"after(:#{name}) has no matching server_action(:#{name})"
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
(after_hooks[name] ||= []) << block
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def after_hooks
|
|
216
|
+
@after_hooks ||= {}
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def action(name, accepted_by: Entities::Specs::ANY, only_if_valid: false, invalidates: nil,
|
|
220
|
+
patch: false, stateless: false, reply_accepted_by: nil, reply_patch: false)
|
|
113
221
|
name = name.to_s
|
|
114
|
-
|
|
222
|
+
reject_reserved_name!(name, "Action")
|
|
223
|
+
actions[name] = Entities::Specs::Action.new(
|
|
224
|
+
name:,
|
|
225
|
+
accepted_by:,
|
|
226
|
+
only_if_valid:,
|
|
227
|
+
invalidates:,
|
|
228
|
+
patch:,
|
|
229
|
+
stateless:,
|
|
230
|
+
reply_accepted_by:,
|
|
231
|
+
reply_patch:
|
|
232
|
+
)
|
|
115
233
|
|
|
116
234
|
define_method(name) {}
|
|
117
235
|
end
|
|
@@ -3,27 +3,34 @@
|
|
|
3
3
|
module Interfacets
|
|
4
4
|
module Shared
|
|
5
5
|
module Facet
|
|
6
|
-
extend
|
|
6
|
+
extend(ActiveSupport::Concern)
|
|
7
7
|
|
|
8
8
|
class_methods do
|
|
9
|
-
attr_accessor
|
|
9
|
+
attr_accessor(:shared, :entity, :store)
|
|
10
10
|
|
|
11
|
-
def mount(
|
|
12
|
-
|
|
11
|
+
def mount(as:, type: nil, polymorphic_key: :type, facet: nil, on_missing: nil,
|
|
12
|
+
validated: false, &block)
|
|
13
|
+
if block
|
|
13
14
|
parent_facet = facet
|
|
14
15
|
facet = Module.new do
|
|
15
|
-
include
|
|
16
|
+
include(Interfacets::Shared::Facet)
|
|
16
17
|
|
|
17
18
|
server_entity do
|
|
18
|
-
include
|
|
19
|
+
include(
|
|
20
|
+
parent_facet.server_entity_module
|
|
21
|
+
)
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
entity_base do
|
|
22
|
-
include
|
|
25
|
+
include(
|
|
26
|
+
parent_facet.entity_base_module
|
|
27
|
+
)
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
client_entity do
|
|
26
|
-
include
|
|
31
|
+
include(
|
|
32
|
+
parent_facet.client_entity_module
|
|
33
|
+
)
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
view_class.view(&parent_facet.view_class.view) if parent_facet.view_class.view
|
|
@@ -32,22 +39,80 @@ module Interfacets
|
|
|
32
39
|
end
|
|
33
40
|
end
|
|
34
41
|
|
|
42
|
+
as_path = Array(as)
|
|
43
|
+
define_nested_association = ->(klass, path, target_mod, target_type) do
|
|
44
|
+
assoc_opts = { type: target_type }
|
|
45
|
+
assoc_opts[:validated] = validated if path.size == 1
|
|
46
|
+
assoc_opts[:polymorphic_key] = polymorphic_key if polymorphic_key
|
|
47
|
+
assoc_opts[:on_missing] = on_missing if on_missing
|
|
48
|
+
|
|
49
|
+
if path.size == 1
|
|
50
|
+
klass.association(
|
|
51
|
+
path.first,
|
|
52
|
+
target_mod,
|
|
53
|
+
**assoc_opts
|
|
54
|
+
)
|
|
55
|
+
else
|
|
56
|
+
head, *tail = path
|
|
57
|
+
klass.association(head) do
|
|
58
|
+
define_nested_association.call(
|
|
59
|
+
self,
|
|
60
|
+
tail,
|
|
61
|
+
target_mod,
|
|
62
|
+
target_type
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
35
68
|
server_entity do
|
|
36
|
-
|
|
69
|
+
target_mod = (
|
|
70
|
+
facet.is_a?(Hash) ?
|
|
71
|
+
facet.transform_values(&:server_entity_module) :
|
|
72
|
+
facet.server_entity_module
|
|
73
|
+
)
|
|
74
|
+
define_nested_association.call(
|
|
75
|
+
self,
|
|
76
|
+
as_path,
|
|
77
|
+
target_mod,
|
|
78
|
+
type
|
|
79
|
+
)
|
|
37
80
|
end
|
|
38
81
|
|
|
39
82
|
client_entity do
|
|
40
|
-
|
|
83
|
+
target_mod = (
|
|
84
|
+
facet.is_a?(Hash) ?
|
|
85
|
+
facet.transform_values(&:client_entity_module) :
|
|
86
|
+
facet.client_entity_module
|
|
87
|
+
)
|
|
88
|
+
define_nested_association.call(
|
|
89
|
+
self,
|
|
90
|
+
as_path,
|
|
91
|
+
target_mod,
|
|
92
|
+
type
|
|
93
|
+
)
|
|
41
94
|
end
|
|
42
95
|
|
|
43
96
|
entity_base do
|
|
44
|
-
|
|
97
|
+
target_mod = (
|
|
98
|
+
facet.is_a?(Hash) ?
|
|
99
|
+
facet.transform_values(&:entity_base_module) :
|
|
100
|
+
facet.entity_base_module
|
|
101
|
+
)
|
|
102
|
+
define_nested_association.call(
|
|
103
|
+
self,
|
|
104
|
+
as_path,
|
|
105
|
+
target_mod,
|
|
106
|
+
type
|
|
107
|
+
)
|
|
45
108
|
end
|
|
46
109
|
end
|
|
47
110
|
|
|
111
|
+
# rubocop:disable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
48
112
|
def view(&block)
|
|
49
113
|
view_class.view(&block)
|
|
50
114
|
end
|
|
115
|
+
# rubocop:enable Style/ArgumentsForwarding, Naming/BlockForwarding
|
|
51
116
|
|
|
52
117
|
def view_class
|
|
53
118
|
@view_class ||= Class.new(Interfacets::Shared::View)
|
|
@@ -64,19 +129,20 @@ module Interfacets
|
|
|
64
129
|
def client_entity_module
|
|
65
130
|
@client_entity_module ||= (
|
|
66
131
|
facet = self
|
|
67
|
-
Module
|
|
68
|
-
|
|
69
|
-
|
|
132
|
+
Module
|
|
133
|
+
.new {
|
|
134
|
+
extend(ActiveSupport::Concern)
|
|
135
|
+
include(facet.entity_base_module)
|
|
136
|
+
|
|
137
|
+
included do
|
|
138
|
+
define_singleton_method(:view) do
|
|
139
|
+
facet.view_class
|
|
140
|
+
end
|
|
70
141
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
facet.view_class
|
|
142
|
+
entity_role("client")
|
|
143
|
+
facet.clients.each { class_exec(&_1) }
|
|
74
144
|
end
|
|
75
|
-
|
|
76
|
-
role("client")
|
|
77
|
-
facet.clients.each { class_exec(&_1) }
|
|
78
|
-
end
|
|
79
|
-
end
|
|
145
|
+
}
|
|
80
146
|
)
|
|
81
147
|
end
|
|
82
148
|
|
|
@@ -85,24 +151,28 @@ module Interfacets
|
|
|
85
151
|
facet = self
|
|
86
152
|
Class
|
|
87
153
|
.new(entity_base_class)
|
|
88
|
-
.tap
|
|
154
|
+
.tap { |k|
|
|
89
155
|
k.class_exec do
|
|
90
|
-
include
|
|
156
|
+
include(facet.client_entity_module)
|
|
91
157
|
|
|
92
158
|
define_singleton_method(:store) do
|
|
93
159
|
@store ||= (
|
|
94
|
-
::Interfacets::Shared::GeneratedStore
|
|
160
|
+
::Interfacets::Shared::GeneratedStore
|
|
161
|
+
.construct(self)
|
|
95
162
|
.tap { self.const_set("Store", _1) }
|
|
96
163
|
)
|
|
97
164
|
end
|
|
98
165
|
|
|
99
166
|
self.manifest = facet.entity_base_class
|
|
100
167
|
|
|
101
|
-
def channel(name)
|
|
102
|
-
Interfacets::Client::System.current_bus.channel(name)
|
|
168
|
+
def channel(name, stream: "default", &block)
|
|
169
|
+
ch = Interfacets::Client::System.current_bus.channel(name)
|
|
170
|
+
target = ch.respond_to?(:builder) ? ch.builder(stream.to_s) : ch
|
|
171
|
+
instance_exec(target, &block) if block
|
|
172
|
+
target
|
|
103
173
|
end
|
|
104
174
|
end
|
|
105
|
-
|
|
175
|
+
}
|
|
106
176
|
)
|
|
107
177
|
end
|
|
108
178
|
|
|
@@ -117,13 +187,14 @@ module Interfacets
|
|
|
117
187
|
def entity_base_module
|
|
118
188
|
@entity_base_module ||= (
|
|
119
189
|
facet = self
|
|
120
|
-
Module
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
190
|
+
Module
|
|
191
|
+
.new {
|
|
192
|
+
extend(ActiveSupport::Concern)
|
|
193
|
+
include(Interfacets::Shared::EntityDsl)
|
|
194
|
+
included do
|
|
195
|
+
facet.bases.each { class_exec(&_1) }
|
|
196
|
+
end
|
|
197
|
+
}
|
|
127
198
|
)
|
|
128
199
|
end
|
|
129
200
|
|
|
@@ -131,8 +202,9 @@ module Interfacets
|
|
|
131
202
|
@entity_base_class ||= (
|
|
132
203
|
facet = self
|
|
133
204
|
|
|
134
|
-
Class
|
|
135
|
-
.
|
|
205
|
+
Class
|
|
206
|
+
.new(Shared::Entity)
|
|
207
|
+
.tap { _1.include(facet.entity_base_module) }
|
|
136
208
|
.tap { facet.const_set("EntityBase", _1) }
|
|
137
209
|
)
|
|
138
210
|
end
|
|
@@ -140,14 +212,15 @@ module Interfacets
|
|
|
140
212
|
def server_entity_module
|
|
141
213
|
@server_entity_module ||= (
|
|
142
214
|
facet = self
|
|
143
|
-
Module
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
215
|
+
Module
|
|
216
|
+
.new {
|
|
217
|
+
extend(ActiveSupport::Concern)
|
|
218
|
+
include(facet.entity_base_module)
|
|
219
|
+
included do
|
|
220
|
+
entity_role("server")
|
|
221
|
+
facet.servers.each { class_exec(&_1) }
|
|
222
|
+
end
|
|
223
|
+
}
|
|
151
224
|
)
|
|
152
225
|
end
|
|
153
226
|
|
|
@@ -155,21 +228,18 @@ module Interfacets
|
|
|
155
228
|
@server_entity_class ||= (
|
|
156
229
|
facet = self
|
|
157
230
|
|
|
158
|
-
Class
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
attr_reader :channel
|
|
162
|
-
def initialize(*a, channel:, **p, &b)
|
|
163
|
-
@channel = channel
|
|
164
|
-
super(*a, **p, &b)
|
|
165
|
-
end
|
|
231
|
+
Class
|
|
232
|
+
.new(entity_base_class) {
|
|
233
|
+
include(facet.server_entity_module)
|
|
166
234
|
|
|
167
|
-
|
|
168
|
-
channel
|
|
169
|
-
|
|
235
|
+
attr_reader(:channel)
|
|
236
|
+
def initialize(*a, channel:, **p, &b)
|
|
237
|
+
@channel = channel
|
|
238
|
+
super(*a, **p, &b)
|
|
239
|
+
end
|
|
170
240
|
|
|
171
|
-
|
|
172
|
-
|
|
241
|
+
self.manifest = facet.entity_base_class
|
|
242
|
+
}
|
|
173
243
|
).tap { facet.const_set("ServerBase", _1) }
|
|
174
244
|
end
|
|
175
245
|
|
|
@@ -185,16 +255,6 @@ module Interfacets
|
|
|
185
255
|
@servers ||= []
|
|
186
256
|
end
|
|
187
257
|
end
|
|
188
|
-
|
|
189
|
-
attr_reader :entity, :view
|
|
190
|
-
def initialize(entity)
|
|
191
|
-
@entity = entity
|
|
192
|
-
@view = self.class.view.new if self.class.view.is_a?(Class)
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def render(channels)
|
|
196
|
-
view.render(entity:, channels:)
|
|
197
|
-
end
|
|
198
258
|
end
|
|
199
259
|
end
|
|
200
260
|
end
|