Class: I18n::Instrument::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/instrument/configurator.rb

Constant Summary collapse

DEFAULT_ENABLED_FILE =
File.join('config', 'enable_i18n_instrumentation')
DEFAULT_JS_ENDPOINT =
'/i18n/instrument.json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigurator

Returns a new instance of Configurator.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/i18n/instrument/configurator.rb', line 9

def initialize
  @js_endpoint = DEFAULT_JS_ENDPOINT
  @stack_trace_prefix = Rails.root.to_s

  @on_check_enabled_proc = -> do
    Rails.root.join(DEFAULT_ENABLED_FILE).exist?
  end

  @on_error_proc = ->(e) { raise e }
  @on_record_proc = ->(*) { }
  @on_lookup_proc = ->(*) { }
end

Instance Attribute Details

#js_endpointObject

Returns the value of attribute js_endpoint.



7
8
9
# File 'lib/i18n/instrument/configurator.rb', line 7

def js_endpoint
  @js_endpoint
end

#stack_trace_prefixObject

Returns the value of attribute stack_trace_prefix.



7
8
9
# File 'lib/i18n/instrument/configurator.rb', line 7

def stack_trace_prefix
  @stack_trace_prefix
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/i18n/instrument/configurator.rb', line 38

def enabled?
  @on_check_enabled_proc.call
end

#on_check_enabled(&block) ⇒ Object



34
35
36
# File 'lib/i18n/instrument/configurator.rb', line 34

def on_check_enabled(&block)
  block ? @on_check_enabled_proc = block : @on_check_enabled_proc
end

#on_error(&block) ⇒ Object



30
31
32
# File 'lib/i18n/instrument/configurator.rb', line 30

def on_error(&block)
  block ? @on_error_proc = block : @on_error_proc
end

#on_lookup(&block) ⇒ Object



22
23
24
# File 'lib/i18n/instrument/configurator.rb', line 22

def on_lookup(&block)
  block ? @on_lookup_proc = block : @on_lookup_proc
end

#on_record(&block) ⇒ Object



26
27
28
# File 'lib/i18n/instrument/configurator.rb', line 26

def on_record(&block)
  block ? @on_record_proc = block : @on_record_proc
end