@@ -36,15 +36,27 @@ module Sentry
3636
3737 THREAD_LOCAL = :sentry_hub
3838
39- def self . sdk_meta
40- META
41- end
39+ class << self
40+ attr_accessor :background_worker
4241
43- def self . utc_now
44- Time . now . utc
45- end
42+ ##### Patch Registration #####
43+ #
44+ def register_patch ( &block )
45+ registered_patches << block
46+ end
4647
47- class << self
48+ def apply_patches ( config )
49+ registered_patches . each do |patch |
50+ patch . call ( config )
51+ end
52+ end
53+
54+ def registered_patches
55+ @registered_patches ||= [ ]
56+ end
57+
58+ ##### Integrations #####
59+ #
4860 # Returns a hash that contains all the integrations that have been registered to the main SDK.
4961 def integrations
5062 @integrations ||= { }
@@ -55,32 +67,16 @@ def register_integration(name, version)
5567 meta = { name : "sentry.ruby.#{ name } " , version : version } . freeze
5668 integrations [ name . to_s ] = meta
5769 end
58- end
5970
60- class << self
71+ ##### Method Delegation #####
72+ #
6173 extend Forwardable
6274
6375 def_delegators :get_current_client , :configuration , :send_event
6476 def_delegators :get_current_scope , :set_tags , :set_extras , :set_user , :set_context
6577
66- attr_accessor :background_worker
67-
68- @@registered_patches = [ ]
69-
70- def register_patch ( &block )
71- registered_patches << block
72- end
73-
74- def apply_patches ( config )
75- registered_patches . each do |patch |
76- patch . call ( config )
77- end
78- end
79-
80- def registered_patches
81- @@registered_patches
82- end
83-
78+ ##### Main APIs #####
79+ #
8480 def init ( &block )
8581 config = Configuration . new
8682 yield ( config ) if block_given?
@@ -193,6 +189,9 @@ def last_event_id
193189 get_current_hub &.last_event_id
194190 end
195191
192+
193+ ##### Helpers #####
194+ #
196195 def sys_command ( command )
197196 result = `#{ command } 2>&1` rescue nil
198197 return if result . nil? || result . empty? || ( $CHILD_STATUS && $CHILD_STATUS. exitstatus != 0 )
@@ -207,6 +206,14 @@ def initialized?
207206 def logger
208207 configuration . logger
209208 end
209+
210+ def sdk_meta
211+ META
212+ end
213+
214+ def utc_now
215+ Time . now . utc
216+ end
210217 end
211218end
212219
0 commit comments