Class: Skein::Context

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname: nil, process_name: nil, process_id: nil, config: nil) ⇒ Context

Instance Methods =====================================================



17
18
19
20
21
# File 'lib/skein/context.rb', line 17

def initialize(hostname: nil, process_name: nil, process_id: nil, config: nil)
  @hostname = (hostname || Skein::Support.hostname).dup.freeze
  @process_name = (process_name || Skein::Support.process_name).dup.freeze
  @process_id = process_id || Skein::Support.process_id
end

Instance Attribute Details

#hostnameObject (readonly)

Properties ===========================================================



4
5
6
# File 'lib/skein/context.rb', line 4

def hostname
  @hostname
end

#process_idObject (readonly)

Returns the value of attribute process_id.



6
7
8
# File 'lib/skein/context.rb', line 6

def process_id
  @process_id
end

#process_nameObject (readonly)

Returns the value of attribute process_name.



5
6
7
# File 'lib/skein/context.rb', line 5

def process_name
  @process_name
end

#reporterObject

Returns the value of attribute reporter.



7
8
9
# File 'lib/skein/context.rb', line 7

def reporter
  @reporter
end

Class Method Details

.defaultObject

Class Methods ========================================================



11
12
13
# File 'lib/skein/context.rb', line 11

def self.default
  @default ||= self.new
end

Instance Method Details

#exception!(*args) ⇒ Object



35
36
37
# File 'lib/skein/context.rb', line 35

def exception!(*args)
  @reporter&.exception!(*args)
end

#ident(object) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/skein/context.rb', line 23

def ident(object)
  # FUTURE: Add pack/unpack methods for whatever format this ends up being
  #         so the components can be extracted by another application for
  #         diagnostic reasons.
  '%s#%d+%s@%s' % [
    @process_name,
    @process_id,
    object.object_id,
    @hostname
  ]
end

#trapObject



39
40
41
42
43
44
45
46
# File 'lib/skein/context.rb', line 39

def trap
  yield

rescue SystemExit
  raise
rescue Object => e
  self.exception!(e)
end