Class: Koi::SummaryList::ItemComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/koi/summary_list/item_component.rb

Instance Method Summary collapse

Methods inherited from Base

#attribute_name, #call, #initialize, #inspect, #raw_value, #to_s

Constructor Details

This class inherits a constructor from Koi::SummaryList::Base

Instance Method Details

#attribute_valueObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/koi/summary_list/item_component.rb', line 10

def attribute_value
  case raw_value
  when Array
    raw_value.join(", ")
  when ActiveStorage::Attached::One
    raw_value.attached? ? link_to(raw_value.filename, url_for(raw_value)) : ""
  when Date, Time, DateTime, ActiveSupport::TimeWithZone
    l(raw_value, format: :admin)
  when TrueClass, FalseClass
    raw_value ? "Yes" : "No"
  else
    raw_value.to_s
  end
end

#render?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/components/koi/summary_list/item_component.rb', line 6

def render?
  !(@skip_blank && raw_value.blank? && raw_value != false)
end