Class: RorVsWild::RailsLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rorvswild/rails_loader.rb

Class Method Summary collapse

Class Method Details

.load_configObject


21
22
23
24
25
26
# File 'lib/rorvswild/rails_loader.rb', line 21

def self.load_config
  if (path = Rails.root.join("config/rorvswild.yml")).exist?
    hash = YAML.load(ERB.new(path.read).result)[Rails.env]
    hash && hash.deep_symbolize_keys
  end
end

.startObject


10
11
12
13
14
15
16
17
18
19
# File 'lib/rorvswild/rails_loader.rb', line 10

def self.start
  return if RorVsWild.agent

  if (config = load_config) && config[:api_key]
    RorVsWild.start(config)
  elsif Rails.env.development?
    require "rorvswild/local"
    RorVsWild::Local.start(config || {})
  end
end

.start_on_rails_initializationObject


3
4
5
6
7
8
# File 'lib/rorvswild/rails_loader.rb', line 3

def self.start_on_rails_initialization
  return if !defined?(Rails)
  Rails::Railtie.initializer "rorvswild.detect_config_file" do
    RorVsWild::RailsLoader.start
  end
end