Class: HakumiComponents::Table::Configs::ColumnEditable
- Inherits:
-
Object
- Object
- HakumiComponents::Table::Configs::ColumnEditable
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/table/configs.rb
Constant Summary collapse
- INPUT_TYPES =
T.let(%i[text number textarea select].freeze, T::Array[Symbol])
- Payload =
T.type_alias { T::Hash[Symbol, Symbol] }
- Input =
T.type_alias do T.nilable(T.any( T::Boolean, InputHash, HakumiComponents::Table::Configs::ColumnEditable )) end
Instance Attribute Summary collapse
-
#input_type ⇒ Object
readonly
Returns the value of attribute input_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input_type: :text) ⇒ ColumnEditable
constructor
A new instance of ColumnEditable.
- #to_h ⇒ Object
Constructor Details
#initialize(input_type: :text) ⇒ ColumnEditable
Returns a new instance of ColumnEditable.
85 86 87 |
# File 'app/components/hakumi_components/table/configs.rb', line 85 def initialize(input_type: :text) @input_type = T.let(INPUT_TYPES.include?(input_type) ? input_type : :text, Symbol) end |
Instance Attribute Details
#input_type ⇒ Object (readonly)
Returns the value of attribute input_type.
90 91 92 |
# File 'app/components/hakumi_components/table/configs.rb', line 90 def input_type @input_type end |
Class Method Details
.coerce(value) ⇒ Object
98 99 100 101 102 103 104 105 106 107 |
# File 'app/components/hakumi_components/table/configs.rb', line 98 def self.coerce(value) return nil if value.nil? || value == false return new if value == true return value if value.is_a?(HakumiComponents::Table::Configs::ColumnEditable) return nil unless value.is_a?(Hash) normalized = value.deep_symbolize_keys input_type = normalized[:input_type] || normalized[:type] new(input_type: normalize_input_type(input_type)) end |
Instance Method Details
#to_h ⇒ Object
93 94 95 |
# File 'app/components/hakumi_components/table/configs.rb', line 93 def to_h { input_type: @input_type } end |