mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow generic types for #described_class and implicit #subject
Add runtime check to ensure #described_class is a type name.
This commit is contained in:
parent
037612d00a
commit
3fc625de3f
1 changed files with 5 additions and 2 deletions
|
@ -27,9 +27,12 @@ module Spectator
|
|||
module Locals
|
||||
include {{parent_module}}::Locals
|
||||
|
||||
{% if what.is_a?(Path) %}
|
||||
{% if what.is_a?(Path) || what.is_a?(Generic) %}
|
||||
def described_class
|
||||
{{what}}
|
||||
{{what}}.tap do |thing|
|
||||
raise "#{thing} must be a type name to use #described_class or #subject,\
|
||||
but it is a #{typeof(thing)}" unless thing.is_a?(Class)
|
||||
end
|
||||
end
|
||||
|
||||
def subject
|
||||
|
|
Loading…
Reference in a new issue