Class: Tapioca::Dsl::Compilers::SorbetTypedPropsConstructor::PropToParamConverter
- Inherits:
-
Object
- Object
- Tapioca::Dsl::Compilers::SorbetTypedPropsConstructor::PropToParamConverter
- Extended by:
- T::Sig
- Includes:
- RBIHelper
- Defined in:
- lib/tapioca/dsl/compilers/sorbet_typed_props_constructor/prop_to_param_converter.rb
Overview
convert sorbet prop to rbi parameter
Defined Under Namespace
Classes: Details
Instance Method Summary collapse
- #create_rbi_parameter ⇒ Object
-
#initialize(name:, details:) ⇒ PropToParamConverter
constructor
A new instance of PropToParamConverter.
Constructor Details
#initialize(name:, details:) ⇒ PropToParamConverter
Returns a new instance of PropToParamConverter.
56 57 58 59 |
# File 'lib/tapioca/dsl/compilers/sorbet_typed_props_constructor/prop_to_param_converter.rb', line 56 def initialize(name:, details:) @name = name @details = details end |
Instance Method Details
#create_rbi_parameter ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/tapioca/dsl/compilers/sorbet_typed_props_constructor/prop_to_param_converter.rb', line 62 def create_rbi_parameter if optional? # NOTE: unfortunately, there is no way to get the actual default # value as code string from within this compiler, as everything # has already been processed at this point. So we use # `T.unsafe(nil)` as stand-in. create_kw_opt_param(parameter_name, type:, default: 'T.unsafe(nil)') else create_kw_param(parameter_name, type:) end end |