Class: Renalware::DefinitionListHelper::DefinitionList

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
Defined in:
app/helpers/renalware/definition_list_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ DefinitionList

Returns a new instance of DefinitionList.



10
11
12
13
# File 'app/helpers/renalware/definition_list_helper.rb', line 10

def initialize(model)
  @model_klass = model.class
  super(model)
end

Instance Method Details

#definition(attribute) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'app/helpers/renalware/definition_list_helper.rb', line 15

def definition(attribute)
  text = @model_klass.human_attribute_name(attribute)
  value = public_send(attribute)
  value = yield(value) if value.present? && block_given?
  capture do
    concat (:dt, text)
    concat (:dd, value)
  end
end