Module: D13n::Metric::Instrumentation::Conductor

Defined in:
lib/d13n/metric/conductor.rb

Defined Under Namespace

Classes: Performance

Class Method Summary collapse

Class Method Details

.clearObject



47
48
49
# File 'lib/d13n/metric/conductor.rb', line 47

def clear
  @concerts = []
end

.concert_by_name(name) ⇒ Object



30
31
32
# File 'lib/d13n/metric/conductor.rb', line 30

def concert_by_name(name)
  @concerts.find { |c| c.name == name }
end

.concertsObject



39
40
41
# File 'lib/d13n/metric/conductor.rb', line 39

def concerts
  @concerts
end

.concerts=(new_concerts) ⇒ Object



43
44
45
# File 'lib/d13n/metric/conductor.rb', line 43

def concerts=(new_concerts)
  @concerts = new_concerts
end

.direct(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/d13n/metric/conductor.rb', line 7

def direct(&block)
  concert = Performance.new
  concert.instance_eval(&block)

  if concert.name
    seen_names = @concerts.map { |c| c.name }.compact
    if seen_names.include?(concert.name)
      D13n.logger.warn("Refusing to re-register Performance block with name '#{concert.name}'")
      return @concerts
    end
  end

  @concerts << concert
end

.perform!Object



22
23
24
25
26
27
28
# File 'lib/d13n/metric/conductor.rb', line 22

def perform!
  @concerts.each do |concert|
    if concert.ready?
      concert.perform
    end
  end
end

.performed?(name) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/d13n/metric/conductor.rb', line 34

def performed?(name)
  concert = concert_by_name(name)
  concert && concert.performed
end