Class: Formstrap::ColorView

Inherits:
ViewModel show all
Includes:
Hintable, Labelable, Validatable, Wrappable
Defined in:
app/models/formstrap/color_view.rb

Instance Method Summary collapse

Methods inherited from ViewModel

#attributes, #initialize, #to_hash

Constructor Details

This class inherits a constructor from ViewModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ViewModel

Instance Method Details

#input_optionsObject



8
9
10
11
12
# File 'app/models/formstrap/color_view.rb', line 8

def input_options
  keys = attributes - %i[attribute form label validate wrapper]
  options = to_h.slice(*keys)
  default_input_options.deep_merge(options)
end

#label_optionsObject



14
15
16
17
18
19
20
21
22
# File 'app/models/formstrap/color_view.rb', line 14

def label_options
  {
    class: ["form-label"],
    attribute: attribute,
    form: form,
    required: required,
    text: label
  }
end

#valueObject



24
25
26
# File 'app/models/formstrap/color_view.rb', line 24

def value
  @form.object&.send(@attribute) || "#000000"
end

#wrapper_optionsObject



28
29
30
31
32
# File 'app/models/formstrap/color_view.rb', line 28

def wrapper_options
  default_wrapper_options.deep_merge(
    {}
  ).deep_merge(@wrapper || {})
end