Class: ConsoleKit::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/console_kit/configuration.rb

Overview

Stores ConsoleKit configurations such as tenant map and context behavior

Defined Under Namespace

Classes: Settings

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
# File 'lib/console_kit/configuration.rb', line 9

def initialize
  @settings = Settings.new(true, nil, nil, 'ApplicationRecord', false)
end

Instance Method Details

#context_classObject



18
19
20
21
22
23
24
# File 'lib/console_kit/configuration.rb', line 18

def context_class
  val = @settings.context_class
  case val
  when String, Symbol then resolve_context_class(val)
  else val
  end
end

#validateObject



26
27
28
29
30
31
# File 'lib/console_kit/configuration.rb', line 26

def validate
  validate!
  true
rescue Error
  false
end

#validate!Object

Raises:



33
34
35
36
37
# File 'lib/console_kit/configuration.rb', line 33

def validate!
  raise Error, 'ConsoleKit: `tenants` is not configured.' if tenants.blank?
  raise Error, 'ConsoleKit: `tenants` must be a Hash.' unless tenants.is_a?(Hash)
  raise Error, 'ConsoleKit: `context_class` is not configured.' if @settings.context_class.blank?
end