Class: HakumiComponents::Table::Configs::RowSelection
- Inherits:
-
Object
- Object
- HakumiComponents::Table::Configs::RowSelection
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/table/configs.rb
Constant Summary collapse
- TYPES =
T.let(%i[checkbox radio].freeze, T::Array[Symbol])
- Input =
T.type_alias { T.nilable(InputHash) }
Instance Attribute Summary collapse
-
#preserve_selected_row_keys ⇒ Object
readonly
Returns the value of attribute preserve_selected_row_keys.
-
#selected_row_keys ⇒ Object
readonly
Returns the value of attribute selected_row_keys.
-
#selections_enabled ⇒ Object
readonly
Returns the value of attribute selections_enabled.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type:, selected_row_keys:, preserve_selected_row_keys:, selections_enabled:) ⇒ RowSelection
constructor
A new instance of RowSelection.
Constructor Details
#initialize(type:, selected_row_keys:, preserve_selected_row_keys:, selections_enabled:) ⇒ RowSelection
Returns a new instance of RowSelection.
136 137 138 139 140 141 142 |
# File 'app/components/hakumi_components/table/configs.rb', line 136 def initialize(type:, selected_row_keys:, preserve_selected_row_keys:, selections_enabled:) @type = T.let(type, Symbol) @selected_row_keys = T.let(selected_row_keys, T::Array[String]) @preserve_selected_row_keys = T.let(preserve_selected_row_keys, T::Boolean) @selections_enabled = T.let(selections_enabled, T::Boolean) validate! end |
Instance Attribute Details
#preserve_selected_row_keys ⇒ Object (readonly)
Returns the value of attribute preserve_selected_row_keys.
151 152 153 |
# File 'app/components/hakumi_components/table/configs.rb', line 151 def preserve_selected_row_keys @preserve_selected_row_keys end |
#selected_row_keys ⇒ Object (readonly)
Returns the value of attribute selected_row_keys.
148 149 150 |
# File 'app/components/hakumi_components/table/configs.rb', line 148 def selected_row_keys @selected_row_keys end |
#selections_enabled ⇒ Object (readonly)
Returns the value of attribute selections_enabled.
151 152 153 |
# File 'app/components/hakumi_components/table/configs.rb', line 151 def selections_enabled @selections_enabled end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
145 146 147 |
# File 'app/components/hakumi_components/table/configs.rb', line 145 def type @type end |
Class Method Details
.coerce(value) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'app/components/hakumi_components/table/configs.rb', line 154 def self.coerce(value) return nil unless value.is_a?(Hash) normalized = value.deep_symbolize_keys selected_row_keys = Array(normalized[:selected_row_keys] || normalized[:selectedRowKeys]).map(&:to_s) new( type: normalize_type(normalized[:type]), selected_row_keys: selected_row_keys, preserve_selected_row_keys: normalized[:preserve_selected_row_keys] == true || normalized[:preserveSelectedRowKeys] == true, selections_enabled: !!normalized[:selections] ) end |