Module: Legion::Extensions::Builder::Actors
- Includes:
- Base
- Included in:
- Core
- Defined in:
- lib/legion/extensions/builders/actors.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Base
#const_defined_two?, #define_constant_two, #define_get, #find_files, #require_files
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
9
10
11
|
# File 'lib/legion/extensions/builders/actors.rb', line 9
def actors
@actors
end
|
Instance Method Details
#actor_files ⇒ Object
55
56
57
|
# File 'lib/legion/extensions/builders/actors.rb', line 55
def actor_files
@actor_files ||= find_files('actors')
end
|
#build_actor_list ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/legion/extensions/builders/actors.rb', line 18
def build_actor_list
actor_files.each do |file|
actor_name = file.split('/').last.sub('.rb', '')
actor_class = "#{lex_class}::Actor::#{actor_name.split('_').collect(&:capitalize).join}"
@actors[actor_name.to_sym] = {
extension: lex_class.to_s.downcase,
extension_name: extension_name,
actor_name: actor_name,
actor_class: Kernel.const_get(actor_class),
type: 'literal'
}
end
end
|
#build_actors ⇒ Object
11
12
13
14
15
16
|
# File 'lib/legion/extensions/builders/actors.rb', line 11
def build_actors
@actors = {}
require_files(actor_files)
build_actor_list
build_meta_actor_list
end
|
48
49
50
51
52
53
|
# File 'lib/legion/extensions/builders/actors.rb', line 48
def build_meta_actor(runner, attr)
define_constant_two('Actor', root: lex_class)
Kernel.const_get("#{attr[:extension_class]}::Actor")
.const_set(runner.to_s.split('_').collect(&:capitalize).join, Class.new(Legion::Extensions::Actors::Subscription))
end
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/legion/extensions/builders/actors.rb', line 32
def build_meta_actor_list
@runners.each do |runner, attr|
next if @actors[runner.to_sym].is_a? Hash
actor_class = "#{attr[:extension_class]}::Actor::#{runner.to_s.split('_').collect(&:capitalize).join}"
build_meta_actor(runner, attr) unless Kernel.const_defined? actor_class
@actors[runner.to_sym] = {
extension: attr[:extension],
extension_name: attr[:extension_name],
actor_name: attr[:runner_name],
actor_class: Kernel.const_get(actor_class),
type: 'meta'
}
end
end
|