lib/legion/extensions/builders/actors.rb in legionio-0.2.0 vs lib/legion/extensions/builders/actors.rb in legionio-0.3.0
- old
+ new
@@ -1,27 +1,26 @@
-# frozen_string_literal: true
-
require_relative 'base'
module Legion
module Extensions
module Builder
module Actors
include Legion::Extensions::Builder::Base
attr_reader :actors
+
def build_actors
@actors = {}
require_files(actor_files)
build_actor_list
build_meta_actor_list
end
def build_actor_list
actor_files.each do |file|
actor_name = file.split('/').last.sub('.rb', '')
- actor_class = lex_class.to_s + '::Actor::' + actor_name.split('_').collect(&:capitalize).join
+ 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),
@@ -32,11 +31,11 @@
def build_meta_actor_list
@runners.each do |runner, attr|
next if @actors[runner.to_sym].is_a? Hash
- actor_class = attr[:extension_class].to_s + '::Actor::' + runner.to_s.split('_').collect(&:capitalize).join
+ 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],
@@ -47,10 +46,10 @@
end
def build_meta_actor(runner, attr)
define_constant_two('Actor', root: lex_class)
- Kernel.const_get(attr[:extension_class].to_s + '::Actor')
+ Kernel.const_get("#{attr[:extension_class]}::Actor")
.const_set(runner.to_s.split('_').collect(&:capitalize).join, Class.new(Legion::Extensions::Actors::Subscription))
end
def actor_files
@actor_files ||= find_files('actors')