Class: DefinitionComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
lib/alveole/components/definition_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(label: nil, value: nil, obj: nil, fieldname: nil, options: {}) ⇒ DefinitionComponent

Returns a new instance of DefinitionComponent.



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/alveole/components/definition_component.rb', line 2

def initialize(label: nil, value: nil, obj: nil, fieldname: nil, options: {})
  super

  @obj = obj
  @fieldname = fieldname
  @value = value || obj&.send(fieldname)
  @value = ApplicationController.helpers.format_value(@value, options)
  @value = '---' if @value.blank?
  @label = label || ApplicationController.helpers.label_for(obj, fieldname)
  @options = options
end