Module: ActiveAdmin::Resource::ActionItems

Included in:
ActiveAdmin::Resource
Defined in:
lib/active_admin/resource/action_items.rb

Instance Method Summary collapse

Instance Method Details

#action_itemsArray

Returns The set of action items for this resource.

Returns:

  • (Array)

    The set of action items for this resource



16
17
18
# File 'lib/active_admin/resource/action_items.rb', line 16

def action_items
  @action_items ||= []
end

#action_items_for(action) ⇒ Array

Returns a set of action items to display for a specific controller action

Parameters:

  • action (String, Symbol)

    the action to retrieve action items for

Returns:

  • (Array)

    Array of ActionItems for the controller actions



36
37
38
# File 'lib/active_admin/resource/action_items.rb', line 36

def action_items_for(action)
  action_items.select{|item| item.display_on?(action) }
end

#add_action_item(options = {}, &block) ⇒ Object

Add a new action item to a resource

Parameters:

  • options (Hash) (defaults to: {})

    valid keys include: :only: A single or array of controller actions to display

    this action item on.
    

    :except: A single or array of controller actions not to

    display this action item on.
    


27
28
29
# File 'lib/active_admin/resource/action_items.rb', line 27

def add_action_item(options = {}, &block)
  self.action_items << ActiveAdmin::ActionItem.new(options, &block)
end

#clear_action_items!Object

Clears all the existing action items for this resource



41
42
43
# File 'lib/active_admin/resource/action_items.rb', line 41

def clear_action_items!
  @action_items = []
end

#initialize(*args) ⇒ Object

Add the default action items to a resource when it’s initialized



10
11
12
13
# File 'lib/active_admin/resource/action_items.rb', line 10

def initialize(*args)
  super
  add_default_action_items
end