Class: IoMonitor::Configuration

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

Constant Summary collapse

DEFAULT_WARN_THRESHOLD =
0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
# File 'lib/io_monitor/configuration.rb', line 7

def initialize
  @publisher = LogsPublisher.new
  @adapters = [ActiveRecordAdapter.new]
  @warn_threshold = DEFAULT_WARN_THRESHOLD
end

Instance Attribute Details

#adaptersObject

Returns the value of attribute adapters.



13
14
15
# File 'lib/io_monitor/configuration.rb', line 13

def adapters
  @adapters
end

#publisherObject (readonly)

Returns the value of attribute publisher.



13
14
15
# File 'lib/io_monitor/configuration.rb', line 13

def publisher
  @publisher
end

#warn_thresholdObject

Returns the value of attribute warn_threshold.



13
14
15
# File 'lib/io_monitor/configuration.rb', line 13

def warn_threshold
  @warn_threshold
end

Instance Method Details

#publish=(value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/io_monitor/configuration.rb', line 15

def publish=(value)
  if value.is_a?(BasePublisher)
    @publisher = value
  elsif (publisher_type = resolve(IoMonitor::PUBLISHERS, value))
    @publisher = publisher_type.new
  else
    supported = IoMonitor::PUBLISHERS.map(&:kind)
    raise ArgumentError, "Only the following publishers are supported: #{supported}."
  end
end