Class: HakumiComponents::Table::Configs::Editable
- Inherits:
-
Object
- Object
- HakumiComponents::Table::Configs::Editable
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/table/configs.rb
Constant Summary collapse
- MODES =
T.let(%i[cell row].freeze, T::Array[Symbol])
- TRIGGERS =
T.let(%i[click dblclick].freeze, T::Array[Symbol])
- InputScalar =
T.type_alias { T.any(T::Boolean, Types::HtmlKey) }
- Payload =
T.type_alias { T::Hash[Symbol, Types::HtmlKey] }
- Input =
T.type_alias { T.nilable(T.any(InputScalar, InputHash, HakumiComponents::Table::Configs::Editable)) }
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(mode: :cell, trigger: :click) ⇒ Editable
constructor
A new instance of Editable.
- #to_h ⇒ Object
Constructor Details
#initialize(mode: :cell, trigger: :click) ⇒ Editable
Returns a new instance of Editable.
20 21 22 23 |
# File 'app/components/hakumi_components/table/configs.rb', line 20 def initialize(mode: :cell, trigger: :click) @mode = T.let(MODES.include?(mode) ? mode : :cell, Symbol) @trigger = T.let(TRIGGERS.include?(trigger) ? trigger : :click, Symbol) end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
26 27 28 |
# File 'app/components/hakumi_components/table/configs.rb', line 26 def mode @mode end |
#trigger ⇒ Object (readonly)
Returns the value of attribute trigger.
26 27 28 |
# File 'app/components/hakumi_components/table/configs.rb', line 26 def trigger @trigger end |
Class Method Details
.coerce(value) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/hakumi_components/table/configs.rb', line 34 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::Editable) if value.is_a?(String) || value.is_a?(Symbol) return new(mode: normalize_mode(value)) end return nil unless value.is_a?(Hash) normalized = value.deep_symbolize_keys new( mode: normalize_mode(normalized[:mode]), trigger: normalize_trigger(normalized[:trigger]) ) end |
Instance Method Details
#to_h ⇒ Object
29 30 31 |
# File 'app/components/hakumi_components/table/configs.rb', line 29 def to_h { mode: @mode, trigger: @trigger } end |