Class: Appsignal::Hooks::Hook

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register(name, hook = self) ⇒ Object



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

def self.register(name, hook=self)
  Appsignal::Hooks.register(name, hook.new)
end

Instance Method Details

#dependencies_present?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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

def dependencies_present?
  raise NotImplementedError
end

#installObject

Raises:

  • (NotImplementedError)


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

def install
  raise NotImplementedError
end

#installed?Boolean

Returns:

  • (Boolean)


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

def installed?
  !! @installed
end

#try_to_install(name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appsignal/hooks.rb', line 24

def try_to_install(name)
  if dependencies_present? && !installed?
    Appsignal.logger.info("Installing #{name} hook")
    begin
      install
      @installed = true
    rescue => ex
      Appsignal.logger.error("Error while installing #{name} hook: #{ex}")
    end
  end
end