Class: SimpleAdmin::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_admin/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Section.



5
6
7
8
9
10
11
12
13
14
# File 'lib/simple_admin/section.rb', line 5

def initialize(interface, section, options={}, &block)
  @interface = interface
  @section = section
  @options = options
  @allow_filters = (section == :index)
#      attributes
#      filters if @allow_filters
  instance_eval(&block) if block_given?
  self
end

Instance Attribute Details

#allow_filters ⇒ Object

Returns the value of attribute allow_filters.



3
4
5
# File 'lib/simple_admin/section.rb', line 3

def allow_filters
  @allow_filters
end

#options ⇒ Object

Returns the value of attribute options.



3
4
5
# File 'lib/simple_admin/section.rb', line 3

def options
  @options
end

#section ⇒ Object

Returns the value of attribute section.



3
4
5
# File 'lib/simple_admin/section.rb', line 3

def section
  @section
end

Instance Method Details

#attributes(attr_options = {}, &block) ⇒ Object



16
17
18
# File 'lib/simple_admin/section.rb', line 16

def attributes(attr_options={}, &block)
  self.options[:attributes] ||= SimpleAdmin::Attributes.new(@interface, self, attr_options, &block)
end

#filters(filter_options = {}, &block) ⇒ Object



20
21
22
23
# File 'lib/simple_admin/section.rb', line 20

def filters(filter_options={}, &block)
  raise "Filters cannot be specified for this section" unless @allow_filters
  self.options[:filters] ||= SimpleAdmin::Filters.new(@interface, self, filter_options, &block)
end


25
26
27
28
29
# File 'lib/simple_admin/section.rb', line 25

def sidebar(sidebar_options={}, &block)
  sidebar_options[:data] = block
  self.options[:sidebars] ||= []
  self.options[:sidebars] << sidebar_options
end