Class: ProMonitor

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

Defined Under Namespace

Classes: Aggregation, Change, Config, Observer, Publisher

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.aggregate_and_publishObject



24
25
26
27
28
29
30
# File 'lib/pro_monitor.rb', line 24

def self.aggregate_and_publish
  aggregation = aggregate_changes do
    yield
  end
  publish_changes(aggregation)
  aggregation
end

.aggregate_changes(options = {}) ⇒ Object

class_attribute :current_aggregation



9
10
11
12
13
14
15
16
17
18
# File 'lib/pro_monitor.rb', line 9

def self.aggregate_changes(options = {})
  previous_aggregation = self.current_aggregation
  self.current_aggregation = aggregation = ProMonitor::Aggregation.new
  begin
    yield
  ensure
    self.current_aggregation = previous_aggregation
  end
  aggregation
end

.configObject



36
37
38
# File 'lib/pro_monitor.rb', line 36

def self.config
  @config ||= ProMonitor::Config.new
end

.configure {|self.config| ... } ⇒ Object

Yields:



40
41
42
# File 'lib/pro_monitor.rb', line 40

def self.configure
  yield(self.config) if block_given?
end

.loggerObject



44
45
46
# File 'lib/pro_monitor.rb', line 44

def self.logger
  Rails.logger
end

.publish_changes(aggregation) ⇒ Object



20
21
22
# File 'lib/pro_monitor.rb', line 20

def self.publish_changes(aggregation)
  ProMonitor::Publisher.new(aggregation).publish
end

Instance Method Details

#aggregating?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/pro_monitor.rb', line 32

def aggregating?
  !!current_aggregation
end