mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Can pass types around (somewhat) at runtime
No need for extra factory classes.
This commit is contained in:
parent
87d9cc438f
commit
9109fc30fd
2 changed files with 5 additions and 11 deletions
|
@ -1,7 +0,0 @@
|
||||||
module Spectator
|
|
||||||
module DSL
|
|
||||||
abstract class AbstractExampleFactory
|
|
||||||
abstract def build(locals : Hash(Symbol, ValueWrapper)) : Example
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +1,11 @@
|
||||||
require "./abstract_example_factory"
|
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
module DSL
|
module DSL
|
||||||
class ExampleFactory(T) < AbstractExampleFactory
|
class ExampleFactory
|
||||||
|
def initialize(@example_type : Example.class)
|
||||||
|
end
|
||||||
|
|
||||||
def build(locals : Hash(Symbol, ValueWrapper)) : Example
|
def build(locals : Hash(Symbol, ValueWrapper)) : Example
|
||||||
T.new(locals)
|
@example_type.new(locals)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue