Skip to content

Instantly share code, notes, and snippets.

@botanicus
Last active February 27, 2019 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save botanicus/278b0741948238c2b10bee2248145abb to your computer and use it in GitHub Desktop.
Save botanicus/278b0741948238c2b10bee2248145abb to your computer and use it in GitHub Desktop.
module DockerProjectManager
abstract class Command
def self.commands : Hash(String, self.class)
@@commands ||= Hash(String, self.class).new
end
macro inherited
command_class = {{ @type.name.id }}
command_name = "{{ @type.name.id }}".split("::").last.downcase
self.commands[command_name] = command_class
end
end
end
class DockerProjectManager::Bootstrap < DockerProjectManager::Command end
Error in x.cr:15: expanding macro
class DockerProjectManager::Bootstrap < DockerProjectManager::Command end
^
in macro 'inherited' /root/docker-project-manager/x.cr:7, line 3:
1. command_class = DockerProjectManager::Bootstrap
2. command_name = "DockerProjectManager::Bootstrap".split("::").last.downcase
> 3. self.commands[command_name] = command_class
4.
instantiating 'DockerProjectManager::Bootstrap.class#commands()'
in x.cr:3: type must be Hash(String, DockerProjectManager::Bootstrap.class), not (Hash(String, DockerProjectManager::Bootstrap.class) | Hash(String, DockerProjectManager::Command.class))
def self.commands : Hash(String, self.class)
^~~~~~~~
Rerun with --error-trace to show a complete error trace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment