Class: Trestle::Table::ActionsColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/trestle/table/actions_column.rb

Defined Under Namespace

Classes: ActionsBuilder, Renderer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ ActionsColumn

Returns a new instance of ActionsColumn.


6
7
8
9
10
11
12
13
14
15
# File 'lib/trestle/table/actions_column.rb', line 6

def initialize(options={}, &block)
  @options = options
  @toolbar = Toolbar.new(ActionsBuilder)

  if block_given?
    @toolbar.append(&block)
  else
    @toolbar.append(&default_actions)
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


4
5
6
# File 'lib/trestle/table/actions_column.rb', line 4

def options
  @options
end

#toolbarObject (readonly)

Returns the value of attribute toolbar


4
5
6
# File 'lib/trestle/table/actions_column.rb', line 4

def toolbar
  @toolbar
end

Instance Method Details

#default_actionsObject


21
22
23
24
25
# File 'lib/trestle/table/actions_column.rb', line 21

def default_actions
  ->(toolbar, instance, admin) do
    toolbar.delete if admin && admin.actions.include?(:destroy)
  end
end

#renderer(table:, template:) ⇒ Object


17
18
19
# File 'lib/trestle/table/actions_column.rb', line 17

def renderer(table:, template:)
  Renderer.new(self, table: table, template: template)
end