Class: RfLogger::ErrorNotification::EnvironmentConstraints

Inherits:
Object
  • Object
show all
Defined in:
lib/rf_logger/notifications/error_notification_environment_constraints.rb

Instance Method Summary collapse

Constructor Details

#initialize(environment, constraints = {}) ⇒ EnvironmentConstraints

Returns a new instance of EnvironmentConstraints.



4
5
6
7
# File 'lib/rf_logger/notifications/error_notification_environment_constraints.rb', line 4

def initialize(environment, constraints={})
  @constraints = constraints
  @environment = environment
end

Instance Method Details

#excluded?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/rf_logger/notifications/error_notification_environment_constraints.rb', line 18

def excluded?
  except = @constraints[:except]
  return false if except.nil?
  except.include?(@environment)
end

#included?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/rf_logger/notifications/error_notification_environment_constraints.rb', line 13

def included?
  only = @constraints[:only]
  only.nil? || only.include?(@environment)
end

#valid_notifier?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rf_logger/notifications/error_notification_environment_constraints.rb', line 9

def valid_notifier?
  @constraints.nil? || (included? && !excluded?)
end