Class: SystemMetrics::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/system_metrics/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/system_metrics/config.rb', line 5

def initialize
  self.store = SystemMetrics::AsyncStore.new
  self.notification_exclude_patterns = []
  self.path_exclude_patterns = [/system\/metrics/, /system_metrics/]
  self.instruments = [
    SystemMetrics::Instrument::ActionController.new,
    SystemMetrics::Instrument::ActionView.new,
    SystemMetrics::Instrument::ActiveRecord.new,
    SystemMetrics::Instrument::Rack.new
  ]
end

Instance Attribute Details

#instrumentsObject

Returns the value of attribute instruments.



3
4
5
# File 'lib/system_metrics/config.rb', line 3

def instruments
  @instruments
end

#notification_exclude_patternsObject

Returns the value of attribute notification_exclude_patterns.



3
4
5
# File 'lib/system_metrics/config.rb', line 3

def notification_exclude_patterns
  @notification_exclude_patterns
end

#path_exclude_patternsObject

Returns the value of attribute path_exclude_patterns.



3
4
5
# File 'lib/system_metrics/config.rb', line 3

def path_exclude_patterns
  @path_exclude_patterns
end

#storeObject

Returns the value of attribute store.



3
4
5
# File 'lib/system_metrics/config.rb', line 3

def store
  @store
end

Instance Method Details

#errorsObject



28
29
30
31
32
33
34
35
36
# File 'lib/system_metrics/config.rb', line 28

def errors
  return nil if valid?
  errors = []
  errors << 'store cannot be nil' if store.nil?
  errors << 'instruments cannot be nil' if instruments.nil?
  errors << 'notification_exclude_patterns cannot be nil' if notification_exclude_patterns.nil?
  errors << 'path_exclude_patterns cannot be nil' if path_exclude_patterns.nil?
  errors.join("\n")
end

#invalid?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/system_metrics/config.rb', line 21

def invalid?
  store.nil? ||
    instruments.nil? ||
    notification_exclude_patterns.nil? ||
    path_exclude_patterns.nil?
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/system_metrics/config.rb', line 17

def valid?
  !invalid?
end