Sha256: 66e385c5795c5486ecda049ee456d98ec743b11cc298ee0d3d0513a149ff4088

Contents?: true

Size: 940 Bytes

Versions: 21

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true
module Kadmin
  class Configuration
    # @return [Logger] An instance of a Ruby compatible logger
    attr_accessor :logger

    # @return [String] the path the engine is mounted at (used for authentication routes)
    attr_accessor :mount_path

    # @return [Array<Kadmin::Navbar::Section, Kadmin::Navbar::Link>] list of admin links or sections
    attr_accessor :navbar_items

    # @return [Boolean] if true, any Kadmin::ApplicationController will catch errors and display a custom page
    attr_accessor :handle_errors

    def initialize
      @mount_path = '/admin'
      @logger = Rails.logger
      @navbar_items = []
      @handle_errors = false
    end

    def add_navbar_items(*items)
      items.each do |item|
        index = @navbar_items.bsearch_index { |navbar_item| navbar_item.text >= item.text }
        @navbar_items.insert(index || @navbar_items.size, item)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
kadmin-0.4.0 lib/kadmin/configuration.rb