Class: Dashboards::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/dashboards/loader.rb

Class Method Summary collapse

Class Method Details

.loadObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dashboards/loader.rb', line 5

def self.load
  config_file = Rails.root.join("config", "dashboards.rb")
  unless File.exist?(config_file)
    Rails.logger.warn "Dashboards configuration file not found at #{config_file}"
    return
  end

  begin
    Class.new do
      extend Dashboards::DSL
      instance_eval(File.read(config_file))
    end
  rescue StandardError => e
    Rails.logger.error "Error loading Dashboards configuration: #{e.message}"
    raise Dashboards::ConfigurationError, "Failed to load Dashboards configuration: #{e.message}"
  end
end