Module: Hoss::Spies Private

Defined in:
lib/hoss/spies.rb,
lib/hoss/spies/http.rb,
lib/hoss/spies/faraday.rb,
lib/hoss/spies/net_http.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: FaradaySpy, HTTPSpy, NetHTTPSpy, Registration

Class Method Summary collapse

Class Method Details

.hook_into(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hoss/spies.rb', line 65

def self.hook_into(name)
  return unless (registration = require_hooks[name])
  return unless safe_defined?(registration.const_name)

  installed[registration.const_name] = registration
  registration.install

  registration.require_paths.each do |path|
    require_hooks.delete path
  end
end

.installedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def self.installed
  @installed ||= {}
end

.register(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
51
52
53
54
55
56
57
# File 'lib/hoss/spies.rb', line 48

def self.register(*args)
  registration = Registration.new(*args)

  if safe_defined?(registration.const_name)
    registration.install
    installed[registration.const_name] = registration
  else
    register_require_hook registration
  end
end

.register_require_hook(registration) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



59
60
61
62
63
# File 'lib/hoss/spies.rb', line 59

def self.register_require_hook(registration)
  registration.require_paths.each do |path|
    require_hooks[path] = registration
  end
end

.require_hooksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def self.require_hooks
  @require_hooks ||= {}
end

.safe_defined?(const_name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


77
78
79
# File 'lib/hoss/spies.rb', line 77

def self.safe_defined?(const_name)
  Util::Inflector.safe_constantize(const_name)
end