Class: Rollgeist::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rollgeist/configuration.rb

Constant Summary collapse

MODES =
%i[log raise].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rollgeist/configuration.rb', line 17

def initialize
  @enabled_environments = %w[development test]
  @ignore_if = nil
  @logger = nil
  @max_reports_per_request = 5
  @mode = nil
  @warn_once = true
  @warn_on_global_id = true
  @warn_on_resave = false
  @warn_on_serialization = true
end

Instance Attribute Details

#enabled_environmentsObject

Returns the value of attribute enabled_environments.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def enabled_environments
  @enabled_environments
end

#ignore_ifObject

Returns the value of attribute ignore_if.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def ignore_if
  @ignore_if
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def logger
  @logger
end

#max_reports_per_requestObject

Returns the value of attribute max_reports_per_request.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def max_reports_per_request
  @max_reports_per_request
end

#modeObject



29
30
31
# File 'lib/rollgeist/configuration.rb', line 29

def mode
  @mode || (Rollgeist.environment == "test" ? :raise : :log)
end

#warn_on_global_idObject

Returns the value of attribute warn_on_global_id.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def warn_on_global_id
  @warn_on_global_id
end

#warn_on_resaveObject

Returns the value of attribute warn_on_resave.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def warn_on_resave
  @warn_on_resave
end

#warn_on_serializationObject

Returns the value of attribute warn_on_serialization.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def warn_on_serialization
  @warn_on_serialization
end

#warn_onceObject

Returns the value of attribute warn_once.



7
8
9
# File 'lib/rollgeist/configuration.rb', line 7

def warn_once
  @warn_once
end

Instance Method Details

#enabled_in?(environment) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rollgeist/configuration.rb', line 33

def enabled_in?(environment)
  enabled_environments.map(&:to_s).include?(environment.to_s)
end

#validate!Object



46
47
48
49
50
51
52
# File 'lib/rollgeist/configuration.rb', line 46

def validate!
  validate_mode!
  validate_limit!
  validate_ignore_predicate!
  validate_environments!
  self
end

#watchpoint_enabled?(watchpoint) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
# File 'lib/rollgeist/configuration.rb', line 37

def watchpoint_enabled?(watchpoint)
  case watchpoint
  when :serialization then warn_on_serialization
  when :global_id then warn_on_global_id
  when :resave then warn_on_resave
  else false
  end
end