Class: ActiveAdmin::BatchAction
- Inherits:
-
Object
- Object
- ActiveAdmin::BatchAction
- Includes:
- Comparable
- Defined in:
- lib/active_admin/batch_actions/resource_extension.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#confirm ⇒ Object
readonly
Returns the value of attribute confirm.
-
#sym ⇒ Object
readonly
Returns the value of attribute sym.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
sort operator.
-
#display_if_block ⇒ Object
Returns the display if block.
-
#initialize(sym, title, options = {}, &block) ⇒ BatchAction
constructor
Create a Batch Action.
-
#priority ⇒ Object
Used for sorting.
Constructor Details
#initialize(sym, title, options = {}, &block) ⇒ BatchAction
Create a Batch Action
Examples:
BatchAction.new :flag
> Will create an action that appears in the action list popover
BatchAction.new( :flag ) { |selection| redirect_to collection_path, :notice => "#{selection.length} users flagged" }
> Will create an action that uses a block to process the request (which receives one paramater of the selected objects)
BatchAction.new( "Perform Long Operation on the" ) { |selection| }
> You can create batch actions with a title instead of a Symbol
BatchAction.new( :flag, :if => proc { can? :flag, AdminUser } ) { |selection| }
> You can provide an optional :if proc to optionally display the batch action
104 105 106 107 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 104 def initialize(sym, title, = {}, &block) @sym, @title, @options, @block, @confirm = sym, title, , block, [:confirm] @block ||= proc {} end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
86 87 88 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 86 def block @block end |
#confirm ⇒ Object (readonly)
Returns the value of attribute confirm.
86 87 88 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 86 def confirm @confirm end |
#sym ⇒ Object (readonly)
Returns the value of attribute sym.
86 87 88 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 86 def sym @sym end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
86 87 88 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 86 def title @title end |
Instance Method Details
#<=>(other) ⇒ Object
sort operator
121 122 123 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 121 def <=>(other) self.priority <=> other.priority end |
#display_if_block ⇒ Object
Returns the display if block. If the block was not explicitly defined a default block always returning true will be returned.
111 112 113 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 111 def display_if_block @options[:if] || proc { true } end |
#priority ⇒ Object
Used for sorting
116 117 118 |
# File 'lib/active_admin/batch_actions/resource_extension.rb', line 116 def priority @options[:priority] || 10 end |