class TypedOperation::Operations::AttributeBuilder
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/typed_operation/operations/attribute_builder.rbs class TypedOperation::Operations::AttributeBuilder def default_provided?: () -> bool def default_value_for_literal: () -> (String | nil | Proc) def define: () -> Symbol def has_default_value_nil?: () -> false def initialize: (Class typed_operation, Symbol parameter_name, (Class | Literal::Types::NilableType) type_signature, Hash options) -> void def needs_to_be_nilable?: () -> true? def prepare_type_signature_for_literal: () -> nil def type_nilable?: () -> bool def union_with_nil_to_support_nil_default: () -> nil def validate_positional_order_params!: () -> nil end
def default_provided?
Experimental RBS support (using type sampling data from the type_fusion
project).
def default_provided?: () -> bool
This signature was generated using 16 samples from 1 application.
def default_provided? @default_key end
def default_value_for_literal
Experimental RBS support (using type sampling data from the type_fusion
project).
def default_value_for_literal: () -> (String | nil | Proc)
This signature was generated using 6 samples from 1 application.
def default_value_for_literal if has_default_value_nil? || type_nilable? -> {} else @default end end
def define(&converter)
Experimental RBS support (using type sampling data from the type_fusion
project).
def define: () -> Symbol
This signature was generated using 5 samples from 1 application.
def define(&converter) # If nilable, then converter should not attempt to call the type converter block if the value is nil coerce_by = if type_nilable? && converter ->(v) { (v == Literal::Null || v.nil?) ? v : converter.call(v) } else converter end @typed_operation.attribute( @name, @signature, default: default_value_for_literal, positional: @positional, reader: @reader, &coerce_by ) end
def has_default_value_nil?
Experimental RBS support (using type sampling data from the type_fusion
project).
def has_default_value_nil?: () -> false
This signature was generated using 12 samples from 1 application.
def has_default_value_nil? default_provided? && @default.nil? end
def initialize(typed_operation, parameter_name, type_signature, options)
Experimental RBS support (using type sampling data from the type_fusion
project).
type TypedOperation__Operations__AttributeBuilder_initialize_options = | positional | TrueClass | default | String | positional | FalseClass | default | String def initialize: (Class typed_operation, Symbol parameter_name, (Class | Literal::Types::NilableType) type_signature, TypedOperation__Operations__AttributeBuilder_initialize_options options) -> void
This signature was generated using 8 samples from 1 application.
def initialize(typed_operation, parameter_name, type_signature, options) @typed_operation = typed_operation @name = parameter_name @signature = type_signature @optional = options[:optional] @positional = options[:positional] @reader = options[:reader] || :public @default_key = options.key?(:default) @default = options[:default] prepare_type_signature_for_literal end
def needs_to_be_nilable?
Experimental RBS support (using type sampling data from the type_fusion
project).
def needs_to_be_nilable?: () -> true?
This signature was generated using 10 samples from 1 application.
def needs_to_be_nilable? @optional && !type_nilable? end
def prepare_type_signature_for_literal
Experimental RBS support (using type sampling data from the type_fusion
project).
def prepare_type_signature_for_literal: () -> nil
This signature was generated using 7 samples from 1 application.
def prepare_type_signature_for_literal @signature = Literal::Types::NilableType.new(@signature) if needs_to_be_nilable? union_with_nil_to_support_nil_default validate_positional_order_params! if @positional end
def type_nilable?
Experimental RBS support (using type sampling data from the type_fusion
project).
def type_nilable?: () -> bool
This signature was generated using 20 samples from 1 application.
def type_nilable? @signature.is_a?(Literal::Types::NilableType) end
def union_with_nil_to_support_nil_default
Experimental RBS support (using type sampling data from the type_fusion
project).
def union_with_nil_to_support_nil_default: () -> nil
This signature was generated using 7 samples from 1 application.
def union_with_nil_to_support_nil_default @signature = Literal::Union.new(@signature, NilClass) if has_default_value_nil? end
def validate_positional_order_params!
Experimental RBS support (using type sampling data from the type_fusion
project).
def validate_positional_order_params!: () -> nil
This signature was generated using 6 samples from 1 application.
def validate_positional_order_params! # Optional ones can always be added after required ones, or before any others, but required ones must be first unless type_nilable? || @typed_operation.optional_positional_parameters.empty? raise ParameterError, "Cannot define required positional parameter '#{@name}' after optional positional parameters" end end