Class: Compony::ModelFields::Color
- Defined in:
- lib/compony/model_fields/color.rb
Instance Attribute Summary
Attributes inherited from Base
#extra_attrs, #model_class, #name, #schema_key
Instance Method Summary collapse
- #simpleform_input(form, _component, name: nil, **input_opts) ⇒ Object
- #value_for(data, controller: nil, **_) ⇒ Object
Methods inherited from Base
#association?, #initialize, #label, #multi?, #schema_line, #simpleform_input_hidden, #transform_and_join
Constructor Details
This class inherits a constructor from Compony::ModelFields::Base
Instance Method Details
#simpleform_input(form, _component, name: nil, **input_opts) ⇒ Object
11 12 13 |
# File 'lib/compony/model_fields/color.rb', line 11 def simpleform_input(form, _component, name: nil, **input_opts) return form.input name || @name, as: :color, **input_opts end |
#value_for(data, controller: nil, **_) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/compony/model_fields/color.rb', line 4 def value_for(data, controller: nil, **_) return transform_and_join(data.send(@name), controller:) do |el| next nil unless el next controller.helpers.raw "#{el} <span style=\"background-color: #{el}\"> </span>" end end |