Sha256: 6fd6a583224a42bcae12464a44eb12298ea77c3713386fc5243342c66c4c1398

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

# typed: strict
# frozen_string_literal: true

require "tapioca/helpers/signatures_helper"

module Tapioca
  module Dsl
    module Helpers
      module ParamHelper
        extend T::Sig
        include SignaturesHelper

        sig { params(name: String, type: String).returns(RBI::TypedParam) }
        def create_param(name, type:)
          create_typed_param(RBI::Param.new(name), type)
        end

        sig { params(name: String, type: String, default: String).returns(RBI::TypedParam) }
        def create_opt_param(name, type:, default:)
          create_typed_param(RBI::OptParam.new(name, default), type)
        end

        sig { params(name: String, type: String).returns(RBI::TypedParam) }
        def create_rest_param(name, type:)
          create_typed_param(RBI::RestParam.new(name), type)
        end

        sig { params(name: String, type: String).returns(RBI::TypedParam) }
        def create_kw_param(name, type:)
          create_typed_param(RBI::KwParam.new(name), type)
        end

        sig { params(name: String, type: String, default: String).returns(RBI::TypedParam) }
        def create_kw_opt_param(name, type:, default:)
          create_typed_param(RBI::KwOptParam.new(name, default), type)
        end

        sig { params(name: String, type: String).returns(RBI::TypedParam) }
        def create_kw_rest_param(name, type:)
          create_typed_param(RBI::KwRestParam.new(name), type)
        end

        sig { params(name: String, type: String).returns(RBI::TypedParam) }
        def create_block_param(name, type:)
          create_typed_param(RBI::BlockParam.new(name), type)
        end

        sig { params(param: RBI::Param, type: String).returns(RBI::TypedParam) }
        def create_typed_param(param, type)
          RBI::TypedParam.new(param: param, type: sanitize_signature_types(type))
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tapioca-0.8.3 lib/tapioca/dsl/helpers/param_helper.rb
tapioca-0.8.2 lib/tapioca/dsl/helpers/param_helper.rb
tapioca-0.7.3 lib/tapioca/dsl/helpers/param_helper.rb
tapioca-0.8.1 lib/tapioca/dsl/helpers/param_helper.rb
tapioca-0.8.0 lib/tapioca/dsl/helpers/param_helper.rb
tapioca-0.7.2 lib/tapioca/dsl/helpers/param_helper.rb
tapioca-0.7.1 lib/tapioca/dsl/helpers/param_helper.rb