Sha256: 7daad13410be1649990ed3eefd9c3e92d4f5ae51ff34d9b3bdc326f505cbc8be
Contents?: true
Size: 966 Bytes
Versions: 19
Compression:
Stored size: 966 Bytes
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) return @options[:only].include?(action.to_sym) if @options[:only] return !@options[:except].include?(action.to_sym) if @options[:except] true end private def normalize_display_options! if @options[:only] @options[:only] = @options[:only].is_a?(Array) ? @options[:only] : [@options[:only]] end if @options[:except] @options[:except] = @options[:except].is_a?(Array) ? @options[:except] : [@options[:except]] end end end end
Version data entries
19 entries across 19 versions & 4 rubygems