Class: Mensa::Action

Inherits:
Object
  • Object
show all
Includes:
ConfigReaders
Defined in:
app/tables/mensa/action.rb

Overview

Provide additional links at the end of the row, with an icon, link and a name

action :delete do

link { |contact| delete_contact_path(contact) }
link_attributes "data-turbo-method" => "delete"
icon "fa-xmark"

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config:, table:) ⇒ Action

Returns a new instance of Action.



18
19
20
21
22
# File 'app/tables/mensa/action.rb', line 18

def initialize(name, config:, table:)
  @name = name
  @table = table
  @config = config
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'app/tables/mensa/action.rb', line 16

def name
  @name
end

#tableObject (readonly)

Returns the value of attribute table.



16
17
18
# File 'app/tables/mensa/action.rb', line 16

def table
  @table
end

Instance Method Details

#icon(record) ⇒ Object



24
25
26
27
28
29
30
# File 'app/tables/mensa/action.rb', line 24

def icon(record)
  if @config[:icon].is_a?(Proc)
    @config[:icon].call(record)
  else
    @config[:icon]
  end
end