diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-31 01:19:31 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:16 -0500 |
commit | f6b6d595958154c4e1c0a588d36bf09e6a0c6a09 (patch) | |
tree | 557d82a880aa24dde3e5e50570a85e380a3060a2 /app | |
parent | f8d23f70b9e5658b109a0180881fb272fccc28ca (diff) |
[Command Tags] Make startup and shutdown calls to all modules
Diffstat (limited to 'app')
-rw-r--r-- | app/lib/command_tag/commands/hello_world.rb | 2 | ||||
-rw-r--r-- | app/lib/command_tag/processor.rb | 7 |
2 files changed, 5 insertions, 4 deletions
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 |