Sha256: cec6c1b48669f862d5e27ec1627a8efa8fda66be8782a0248210a1989a031330

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

require "yaml"

module ActiveAdminMenu
  class << self
    def configure
      yield(config)
    end

    def config
      @_config ||= Config.new
    end
  end

  class Config
    attr_reader :source
    attr_accessor :namespace, :uncategorize_key_name, :i18n_scope_prefix

    def initialize
      @source                = {}
      @uncategorize_key_name = "root"
      @i18n_scope_prefix     = { parent: "active_admin.menu", label: "active_admin.menu" }
    end

    def source=(value)
      @source = value.is_a?(Hash) ? value : YAML.load_file(value.to_s)
    end

    def namespaced_source
      source[namespace] || source
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_admin_menu-0.1.2 lib/active_admin_menu/config.rb
active_admin_menu-0.1.1 lib/active_admin_menu/config.rb