Module: LibraryDetection

Defined in:
lib/one_apm/support/library_detection.rb

Defined Under Namespace

Classes: Dependent

Class Method Summary collapse

Class Method Details

.defer(&block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/one_apm/support/library_detection.rb', line 9

def defer(&block)
  item = Dependent.new
  item.instance_eval(&block)

  if item.name
    seen_names = @items.map { |i| i.name }.compact
    if seen_names.include?(item.name)
      OneApm::Manager.logger.warn("Refusing to re-register LibraryDetection block with name '#{item.name}'")
      return @items
    end
  end

  @items << item
end

.dependency_by_name(name) ⇒ Object



32
33
34
# File 'lib/one_apm/support/library_detection.rb', line 32

def dependency_by_name(name)
  @items.find {|i| i.name == name }
end

.detect!Object



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

def detect!
  @items.each do |item|
    if item.dependencies_satisfied?
      item.execute
    end
  end
end

.installed?(name) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/one_apm/support/library_detection.rb', line 36

def installed?(name)
  item = dependency_by_name(name)
  item && item.executed
end

.itemsObject



41
42
43
# File 'lib/one_apm/support/library_detection.rb', line 41

def items
  @items
end

.items=(new_items) ⇒ Object



45
46
47
# File 'lib/one_apm/support/library_detection.rb', line 45

def items=(new_items)
  @items = new_items
end