Class: ActiveAdmin::Sidebar::Section

Inherits:
Object
  • Object
show all
Includes:
OptionalDisplay
Defined in:
lib/active_admin/sidebar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionalDisplay

#display_on?

Constructor Details

#initialize(name, options = {}, &block) ⇒ Section

Returns a new instance of Section.



9
10
11
12
# File 'lib/active_admin/sidebar.rb', line 9

def initialize(name, options = {}, &block)
  @name, @options, @block = name, options, block
  normalize_display_options!
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



7
8
9
# File 'lib/active_admin/sidebar.rb', line 7

def block
  @block
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/active_admin/sidebar.rb', line 7

def name
  @name
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/active_admin/sidebar.rb', line 7

def options
  @options
end

Instance Method Details

#iconObject



23
24
25
# File 'lib/active_admin/sidebar.rb', line 23

def icon
  options[:icon] if icon?
end

#icon?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/active_admin/sidebar.rb', line 19

def icon?
  options[:icon]
end

#idObject

The id gets used for the div in the view



15
16
17
# File 'lib/active_admin/sidebar.rb', line 15

def id
  name.to_s.downcase.underscore + '_sidebar_section'
end

#partial_nameObject

If a block is not passed in, the name of the partial to render



37
38
39
# File 'lib/active_admin/sidebar.rb', line 37

def partial_name
  options[:partial] || "#{name.to_s.downcase.gsub(' ', '_')}_sidebar"
end

#titleObject

The title gets displayed within the section in the view



28
29
30
31
32
33
34
# File 'lib/active_admin/sidebar.rb', line 28

def title
  begin
    I18n.t!("active_admin.sidebars.#{name.to_s}")
  rescue I18n::MissingTranslationData
    name.to_s.titlecase
  end
end