Can pass types around (somewhat) at runtime

No need for extra factory classes.
This commit is contained in:
Michael Miller 2018-09-23 12:03:52 -06:00
parent 87d9cc438f
commit 9109fc30fd
2 changed files with 5 additions and 11 deletions

View file

@ -1,7 +0,0 @@
module Spectator
module DSL
abstract class AbstractExampleFactory
abstract def build(locals : Hash(Symbol, ValueWrapper)) : Example
end
end
end

View file

@ -1,10 +1,11 @@
require "./abstract_example_factory"
module Spectator
module DSL
class ExampleFactory(T) < AbstractExampleFactory
class ExampleFactory
def initialize(@example_type : Example.class)
end
def build(locals : Hash(Symbol, ValueWrapper)) : Example
T.new(locals)
@example_type.new(locals)
end
end
end