Sha256: af7ea8ec3e1946fe3a4eef52a49ddd27a547d9f92c9d8a8a4bd73c07a825352d

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

module SimpleAdmin
  class Section
    attr_accessor :options, :section, :allow_filters

    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

    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

1 entries across 1 versions & 1 rubygems

Version Path
simple_admin-0.7.1 lib/simple_admin/section.rb