Class: ScoutApm::Context

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



8
9
10
11
# File 'lib/scout_apm/context.rb', line 8

def initialize
  @extra = {}
  @user = {}
end

Class Method Details

.add(hash) ⇒ Object

Convenience accessor so you can just call @ScoutAPM::Context#add@



34
35
36
# File 'lib/scout_apm/context.rb', line 34

def self.add(hash)
  self.current.add(hash)
end

.add_user(hash) ⇒ Object

Convenience accessor so you can just call @ScoutAPM::Context#add_user@



39
40
41
# File 'lib/scout_apm/context.rb', line 39

def self.add_user(hash)
  self.current.add_user(hash)
end

.currentObject



19
20
21
# File 'lib/scout_apm/context.rb', line 19

def self.current
  RequestManager.lookup.context
end

Instance Method Details

#add(hash) ⇒ Object

Add context ScoutApm::Context.add(account: current_account.name)



25
26
27
# File 'lib/scout_apm/context.rb', line 25

def add(hash)
  update_context(:extra,hash)
end

#add_user(hash) ⇒ Object



29
30
31
# File 'lib/scout_apm/context.rb', line 29

def add_user(hash)
  update_context(:user,hash)
end

#to_hashObject

Generates a hash representation of the Context. Example: => 100, :user => {:ip => ‘127.0.0.1’}



15
16
17
# File 'lib/scout_apm/context.rb', line 15

def to_hash
  @extra.merge({:user => @user})
end