class KonoUtilsBootstrapView4::EditableField
PORO che si occupa di gestire un campo da editare. questo serve per poter gestire le casistiche provenienti dagli editable attributes, che consistono in semplisy symbols o in hash che rappresentano le relazioni
Public Class Methods
editable_fields_to_field_array(attributes)
click to toggle source
@return [Array<KonoUtilsBootstrapView4::EditableField>]
# File lib/kono_utils_bootstrap_view4/editable_field.rb, line 50 def self.editable_fields_to_field_array(attributes) attributes.collect do |s| if s.is_a?(Hash) s.collect {|k, v| KonoUtilsBootstrapView4::EditableField.new({k => v})} else KonoUtilsBootstrapView4::EditableField.new(s) end end.flatten end
new(f)
click to toggle source
# File lib/kono_utils_bootstrap_view4/editable_field.rb, line 10 def initialize(f) @field = f end
Public Instance Methods
inner_fields()
click to toggle source
Nei casi di campi nested, questo metodo restituisce un array di campi interni, normalizzati a EditableField
# File lib/kono_utils_bootstrap_view4/editable_field.rb, line 44 def inner_fields is_nested? ? self.class.editable_fields_to_field_array(@field[name]) : [] end
is_nested?()
click to toggle source
Controlla se il campo รจ di tipo nested (un hash con chiave ed una serie di campi interni)
# File lib/kono_utils_bootstrap_view4/editable_field.rb, line 38 def is_nested? @field.is_a?(Hash) end
name()
click to toggle source
Restituisce il symbol che rappresenta il campo da editare
# File lib/kono_utils_bootstrap_view4/editable_field.rb, line 18 def name if @field.is_a?(Hash) @field.keys.first else @field.to_sym end end