Hide method to infer type of first in collection in given macro

This was a bit of a hack.
This commit is contained in:
Michael Miller 2018-09-15 23:38:07 -06:00
parent 80fbe89b4c
commit fa73bf3a60
1 changed files with 6 additions and 2 deletions

View File

@ -64,11 +64,15 @@ module Spectator
{{collection}}
end
def self.{{var_name}}
def self.%first
%collection.first
end
\{% ::Spectator::Definitions::ALL[@type.id][:given] << {name: "{{var_name}}".id, collection: "{{collection}}".id, type_def: (@type.id + ".{{var_name}}").id} %}
\{% ::Spectator::Definitions::ALL[@type.id][:given] << {
name: "{{var_name}}".id,
collection: "{{collection}}".id,
type_def: (@type.id + '.' + :%first.stringify[1..-1]).id
} %}
{{block.body}}
end