Sha256: b75fbbda98d09edc4328e97fc00ea0efb36acc1ccd95c0936bcc67711ac1230e
Contents?: true
Size: 1.04 KB
Versions: 63
Compression:
Stored size: 1.04 KB
Contents
module ActiveAdmin # 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 module OptionalDisplay 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 private def normalize_display_options! @options[:only] = Array(@options[:only]) if @options[:only] @options[:except] = Array(@options[:except]) if @options[:except] end end end
Version data entries
63 entries across 63 versions & 6 rubygems