Class: Tapioca::Dsl::Helpers::ActiveRecordColumnTypeHelper

Inherits:
Object
  • Object
show all
Includes:
RBIHelper
Defined in:
lib/tapioca/dsl/helpers/active_record_column_type_helper.rb

Defined Under Namespace

Classes: ColumnTypeOption

Constant Summary

Constants included from RBIHelper

RBIHelper::TYPE_PARAMETER_MATCHER

Constants included from SorbetHelper

SorbetHelper::FEATURE_REQUIREMENTS, SorbetHelper::SORBET_BIN, SorbetHelper::SORBET_EXE_PATH_ENV_VAR, SorbetHelper::SORBET_GEM_SPEC, SorbetHelper::SORBET_PAYLOAD_URL, SorbetHelper::SPOOM_CONTEXT

Instance Method Summary collapse

Methods included from RBIHelper

#as_nilable_type, #as_non_nilable_type, #create_block_param, #create_kw_opt_param, #create_kw_param, #create_kw_rest_param, #create_opt_param, #create_param, #create_rest_param, #create_typed_param, #extract_type_parameters, #sanitize_signature_types, serialize_type_variable, #valid_method_name?, #valid_parameter_name?

Methods included from SorbetHelper

#sorbet, #sorbet_path, #sorbet_supports?

Constructor Details

#initialize(constant, column_type_option: ColumnTypeOption::Persisted) ⇒ ActiveRecordColumnTypeHelper

: (singleton(ActiveRecord::Base) constant, ?column_type_option: ColumnTypeOption) -> void



56
57
58
59
# File 'lib/tapioca/dsl/helpers/active_record_column_type_helper.rb', line 56

def initialize(constant, column_type_option: ColumnTypeOption::Persisted)
  @constant = constant
  @column_type_option = column_type_option
end

Instance Method Details

#type_for(attribute_name, column_name = attribute_name) ⇒ Object

: (String attribute_name, ?String column_name) -> [String, String]



62
63
64
65
66
# File 'lib/tapioca/dsl/helpers/active_record_column_type_helper.rb', line 62

def type_for(attribute_name, column_name = attribute_name)
  return id_type if attribute_name == "id"

  column_type_for(column_name)
end