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, render_context = self) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/active_admin/helpers/optional_display.rb', line 18 def display_on?(action, render_context = self) return false if @options[:only] && !@options[:only].include?(action.to_sym) return false if @options[:except] && @options[:except].include?(action.to_sym) case condition = @options[:if] when Symbol, String render_context.public_send condition when Proc render_context.instance_exec &condition else true end end |