Class: ActiveAdmin::SidebarSection

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

Direct Known Subclasses

Filters::ActiveSidebar

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionalDisplay

#display_on?

Constructor Details

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

Returns a new instance of SidebarSection.


8
9
10
11
12
13
# File 'lib/active_admin/sidebar_section.rb', line 8

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

Instance Attribute Details

#blockObject

Returns the value of attribute block


6
7
8
# File 'lib/active_admin/sidebar_section.rb', line 6

def block
  @block
end

#nameObject

Returns the value of attribute name


6
7
8
# File 'lib/active_admin/sidebar_section.rb', line 6

def name
  @name
end

#optionsObject

Returns the value of attribute options


6
7
8
# File 'lib/active_admin/sidebar_section.rb', line 6

def options
  @options
end

Instance Method Details

#custom_classObject


30
31
32
# File 'lib/active_admin/sidebar_section.rb', line 30

def custom_class
  options[:class]
end

#idObject

The id gets used for the div in the view


16
17
18
# File 'lib/active_admin/sidebar_section.rb', line 16

def id
  "#{name.downcase.underscore}_sidebar_section".parameterize
end

#partial_nameObject

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


26
27
28
# File 'lib/active_admin/sidebar_section.rb', line 26

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

#priorityObject


34
35
36
# File 'lib/active_admin/sidebar_section.rb', line 34

def priority
  options[:priority] || 10
end

#titleObject

The title gets displayed within the section in the view


21
22
23
# File 'lib/active_admin/sidebar_section.rb', line 21

def title
  I18n.t("active_admin.sidebars.#{name}", default: name.titlecase)
end