Class: Satis::InfoItem::Component
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Satis::InfoItem::Component
- Defined in:
- app/components/satis/info_item/component.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from ApplicationComponent
Instance Method Summary collapse
- #class_name ⇒ Object
-
#initialize(name, *args, &block) ⇒ Component
constructor
A new instance of Component.
- #string_contents ⇒ Object
Methods inherited from ApplicationComponent
Constructor Details
#initialize(name, *args, &block) ⇒ Component
Returns a new instance of Component.
8 9 10 11 12 13 14 15 16 |
# File 'app/components/satis/info_item/component.rb', line 8 def initialize(name, *args, &block) super @name = name @args = args @options = args. @group = [:group] @icon = [:icon] @placeholder = [:placeholder] || '—' end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
6 7 8 |
# File 'app/components/satis/info_item/component.rb', line 6 def group @group end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
6 7 8 |
# File 'app/components/satis/info_item/component.rb', line 6 def icon @icon end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'app/components/satis/info_item/component.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'app/components/satis/info_item/component.rb', line 6 def @options end |
Instance Method Details
#class_name ⇒ Object
38 39 40 |
# File 'app/components/satis/info_item/component.rb', line 38 def class_name "satis-info-item #{group}-info-item #{css_class_for_name}-info-item #{[:class]}" end |
#string_contents ⇒ Object
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 = [: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 |