Class: Katalyst::Tables::Label
- Inherits:
-
Object
- Object
- Katalyst::Tables::Label
- Defined in:
- app/components/katalyst/tables/label.rb
Instance Method Summary collapse
- #call ⇒ Object (also: #to_s)
-
#initialize(collection:, column:, label: nil) ⇒ Label
constructor
A new instance of Label.
- #inspect ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(collection:, column:, label: nil) ⇒ Label
Returns a new instance of Label.
6 7 8 9 10 |
# File 'app/components/katalyst/tables/label.rb', line 6 def initialize(collection:, column:, label: nil) @collection = collection @column = column @label = label end |
Instance Method Details
#call ⇒ Object Also known as: to_s
24 25 26 27 28 |
# File 'app/components/katalyst/tables/label.rb', line 24 def call ActionView::OutputBuffer.new.tap do |output| output << value.to_s end.to_s end |
#inspect ⇒ Object
32 33 34 |
# File 'app/components/katalyst/tables/label.rb', line 32 def inspect "#<#{self.class.name} column: #{@column.inspect} value: #{value.inspect}>" end |
#value ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/katalyst/tables/label.rb', line 12 def value return @value if defined?(@value) @value = if !@label.nil? @label elsif @collection.model.present? @collection.model.human_attribute_name(@column) else @column.to_s.humanize.capitalize end end |