Class: DefinitionComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- DefinitionComponent
- Defined in:
- lib/alveole/components/definition_component.rb
Instance Method Summary collapse
-
#initialize(label: nil, value: nil, obj: nil, fieldname: nil, options: {}) ⇒ DefinitionComponent
constructor
A new instance of DefinitionComponent.
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, ) @value = '---' if @value.blank? @label = label || ApplicationController.helpers.label_for(obj, fieldname) @options = end |