class Yoda::Parsing::TypeParser::Generator
Public Class Methods
create_function_type(context, param_types, return_type)
click to toggle source
# File lib/yoda/parsing/type_parser.rb, line 98 def self.create_function_type(context, param_types, return_type) func_options = param_types.each_with_object({ context: context, return_type: return_type }).with_index do |(param, func_options), index| case param.kind when :required if func_options[:rest_parameter] func_options[:post_parameters] ||= [] func_options[:post_parameters].push(param.type) else func_options[:required_parameters] ||= [] func_options[:required_parameters].push(param.type) end when :optional func_options[:optional_parameters] ||= [] func_options[:optional_parameters].push(param.type) when :rest func_options[:rest_parameter] = param.type when :required_keyword func_options[:required_keyword_parameters] ||= [] func_options[:required_keyword_parameters].push(param.keyword, param.type) when :optional_keyword func_options[:optional_keyword_parameters] ||= [] func_options[:optional_keyword_parameters].push(param.keyword, param.type) when :keyword_rest func_options[:keyword_rest_parameter] = param.type when :block func_options[:block_parameter] = param.type end end Model::Types::FunctionType.new(func_options) end