Class: Appsignal::Hooks::Hook

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHook

Returns a new instance of Hook.



24
25
26
# File 'lib/appsignal/hooks.rb', line 24

def initialize
  @installed = false
end

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)


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

def dependencies_present?
  raise NotImplementedError
end

#installObject

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/appsignal/hooks.rb', line 48

def install
  raise NotImplementedError
end

#installed?Boolean

Returns:

  • (Boolean)


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

def installed?
  @installed
end

#try_to_install(name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/appsignal/hooks.rb', line 28

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