Sha256: dabe854a51c081f4eb6f104b959747a04ae52c446ccc6460d591a0fee5599ac8

Contents?: true

Size: 927 Bytes

Versions: 3

Compression:

Stored size: 927 Bytes

Contents

module SimpleAdmin
  class Section
    attr_accessor :options, :section

    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?
    end

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

    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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_admin-0.3.0 lib/simple_admin/section.rb
simple_admin-0.2.1 lib/simple_admin/section.rb
simple_admin-0.1.0 lib/simple_admin/section.rb