Module: ActiveAdmin::OptionalDisplay

Included in:
ActionItem, SidebarSection
Defined in:
lib/active_admin/helpers/optional_display.rb

Overview

Shareable module to give a #display_on?(action) method which returns true or false depending on an options hash.

The options hash accepts:

:only => :index :only => [:index, :show] :except => :index :except => [:index, :show]

call #normalize_display_options! after @options has been set to ensure that the display options are setup correctly

Instance Method Summary collapse

Instance Method Details

#display_on?(action) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/active_admin/helpers/optional_display.rb', line 17

def display_on?(action)
  return @options[:only].include?(action.to_sym) if @options[:only]
  return !@options[:except].include?(action.to_sym) if @options[:except]
  true
end