Method: Satis::InfoItem::Component#string_contents

Defined in:
app/components/satis/info_item/component.rb

#string_contentsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/components/satis/info_item/component.rb', line 18

def string_contents
  @content = options[:content]
  @content = @content.call if @content.respond_to?(:call)

  case @content.presence
  when Time
    @content.strftime('%Y-%m-%d %H:%M')
  when ActiveRecord::Base
    @content.try(:human_name) || @content.try(:name) || "#{@content.class} ##{@content.id}"
  when Symbol
    @content.to_s.humanize
  when ActiveSupport::SafeBuffer
    @content
  when nil
    @placeholder
  else
    @content
  end
end