Class: ScoutApm::FrameworkIntegrations::Rails2

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/framework_integrations/rails_2.rb

Instance Method Summary collapse

Instance Method Details

#application_nameObject



22
23
24
25
26
27
28
29
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 22

def application_name
  if defined?(::Rails)
    ::Rails.application.class.to_s.
      sub(/::Application$/, '')
  end
rescue
  nil
end

#database_engineObject

Attempts to determine the database engine being used



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 36

def database_engine
  default = :mysql

  if defined?(ActiveRecord::Base)
    config = ActiveRecord::Base.configurations[env]
    if config && config["adapter"]
      case config["adapter"].to_s
      when "postgres"   then :postgres
      when "postgresql" then :postgres
      when "postgis"    then :postgres
      when "sqlite3"    then :sqlite
      when "mysql"      then :mysql
      else default
      end
    else
      default
    end
  else
    default
  end
rescue
  default
end

#envObject



31
32
33
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 31

def env
  RAILS_ENV.dup
end

#human_nameObject



8
9
10
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 8

def human_name
  "Rails"
end

#nameObject



4
5
6
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 4

def name
  :rails
end

#present?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 16

def present?
  defined?(::Rails) &&
    defined?(ActionController) &&
    Rails::VERSION::MAJOR < 3
end

#versionObject



12
13
14
# File 'lib/scout_apm/framework_integrations/rails_2.rb', line 12

def version
  Rails::VERSION::STRING
end