From f6b6d595958154c4e1c0a588d36bf09e6a0c6a09 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Fri, 31 Jul 2020 01:19:31 -0500 Subject: [Command Tags] Make startup and shutdown calls to all modules --- app/lib/command_tag/commands/hello_world.rb | 2 +- app/lib/command_tag/processor.rb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'app/lib/command_tag') diff --git a/app/lib/command_tag/commands/hello_world.rb b/app/lib/command_tag/commands/hello_world.rb index d67f65333..cc770ef80 100644 --- a/app/lib/command_tag/commands/hello_world.rb +++ b/app/lib/command_tag/commands/hello_world.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module CommandTag::Commands::HelloWorld - def initialize_helloworld! + def handle_helloworld_startup @vars['hello_world'] = ['Hello, world!'] end diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb index cb447f851..414c08638 100644 --- a/app/lib/command_tag/processor.rb +++ b/app/lib/command_tag/processor.rb @@ -49,7 +49,7 @@ class CommandTag::Processor reset_status_caches - initialize_handlers! + all_handlers!(:startup) parse_statements @@ -79,13 +79,14 @@ class CommandTag::Processor end execute_statements(:at_end) + all_handlers!(:shutdown) reset_status_caches end private - def initialize_handlers! - self.class.instance_methods.grep(/\Ainitialize_\w+!\z/).each do |name| + def all_handlers!(affix) + self.class.instance_methods.grep(/\Ahandle_\w+_#{affix}\z/).each do |name| public_send(name) end end -- cgit