Sha256: 09612cd5f52ee6ce48948b20468b35ed23444669b79209a27d784edade4a99fe
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
class Houndstooth::Environment class Parameter < Type # Note: Parameters aren't *really* a type, but we need `resolve_type_if_pending` # @return [Name] attr_reader :name # @return [Type] attr_accessor :type # @return [Boolean] attr_reader :optional alias optional? optional def initialize(name, type, optional: false) @name = name @type = type @optional = optional end def resolve_all_pending_types(environment, context:) @type = resolve_type_if_pending(type, context, environment) end def substitute_type_parameters(instance, call_type_args) clone.tap do |t| t.type = t.type.substitute_type_parameters(instance, call_type_args) end end end class PositionalParameter < Parameter def rbs if name "#{optional? ? '?' : ''}#{type.rbs} #{name}" else "#{optional? ? '?' : ''}#{type.rbs}" end end end class KeywordParameter < Parameter def rbs "#{optional? ? '?' : ''}#{name}: #{type.rbs}" end end class BlockParameter < Parameter def rbs "#{optional? ? '?' : ''}{ #{type.rbs} }" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
houndstooth-0.1.0 | lib/houndstooth/environment/types/method/parameters.rb |