Class: Airbrake::Config::Validator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/config/validator.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Validator validates values of Airbrake::Config options. A valid config is a config that guarantees that data can be sent to Airbrake given its configuration.

Since:

  • v1.5.0

Constant Summary collapse

VALID_ENV_TYPES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns the list of allowed types to configure the environment option.

Returns:

  • (Array<Class>)

    the list of allowed types to configure the environment option

Since:

  • v1.5.0

[NilClass, String, Symbol].freeze

Class Method Summary collapse

Class Method Details

.check_notify_ability(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether the given config allows sending data to Airbrake. It doesn’t matter if it’s valid or invalid.

Parameters:

Since:

  • v4.1.0



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/airbrake-ruby/config/validator.rb', line 44

def check_notify_ability(config)
  promise = Airbrake::Promise.new

  unless config.error_notifications
    return promise.reject('error notifications are disabled')
  end

  if ignored_environment?(config)
    return promise.reject(
      "current environment '#{config.environment}' is ignored",
    )
  end

  promise.resolve(:ok)
end

.validate(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Since:

  • v4.1.0



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/airbrake-ruby/config/validator.rb', line 17

def validate(config)
  promise = Airbrake::Promise.new

  unless valid_project_id?(config)
    return promise.reject(':project_id is required')
  end

  unless valid_project_key?(config)
    return promise.reject(':project_key is required')
  end

  unless valid_environment?(config)
    return promise.reject(
      "the 'environment' option must be configured " \
      "with a Symbol (or String), but '#{config.environment.class}' was " \
      "provided: #{config.environment}",
    )
  end

  promise.resolve(:ok)
end