Sha256: 2b4705671c537af6f7ca5cacedb1f6ae6b110dd0879aa69096c07c6bf0694c5c

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module ActiveAdmin
  class ResourceController < ::InheritedViews::Base
    
    module PageConfigurations
      extend ActiveSupport::Concern

      included do
        helper_method :index_config
        helper_method :show_config
      end

      module ClassMethods

        def set_page_config(page, options, &block)
          active_admin_config.page_configs[page] = ActiveAdmin::PageConfig.new(options, &block)
        end

        def get_page_config(page)
          active_admin_config.page_configs[page]
        end

        def reset_page_config!(page)
          active_admin_config.page_configs[page] = nil
        end

        # Define the getting and re-setter for each configurable page
        [:index, :show].each do |page|
          # eg: index_config
          define_method :"#{page}_config" do
            get_page_config(page)
          end

          # eg: reset_index_config!
          define_method :"reset_#{page}_config!" do
            reset_page_config! page
          end
        end

      end

      protected

      def index_config
        @index_config ||= self.class.index_config
      end

      def show_config
        @show_config ||= self.class.show_config
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activeadmin-0.2.2 lib/active_admin/resource_controller/page_configurations.rb
activeadmin-0.2.1 lib/active_admin/resource_controller/page_configurations.rb
activeadmin-0.2.0 lib/active_admin/resource_controller/page_configurations.rb