Class: Zenrows::HookConfigurator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/zenrows/client.rb

Overview

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

Helper class for per-client hook configuration

Provides the same hook registration DSL as Configuration.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(hooks) ⇒ HookConfigurator

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 a new instance of HookConfigurator.

Parameters:

  • hooks (Hooks)

    Hook registry to configure

Since:

  • 0.1.0



228
229
230
# File 'lib/zenrows/client.rb', line 228

def initialize(hooks)
  @hooks = hooks
end

Instance Method Details

#add_subscriber(subscriber) ⇒ 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.

Add a subscriber object

Since:

  • 0.1.0



263
264
265
266
# File 'lib/zenrows/client.rb', line 263

def add_subscriber(subscriber)
  @hooks.add_subscriber(subscriber)
  self
end

#after_request(callable = nil, &block) ⇒ 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.

Register an after_request callback

Since:

  • 0.1.0



239
240
241
242
# File 'lib/zenrows/client.rb', line 239

def after_request(callable = nil, &block)
  @hooks.register(:after_request, callable, &block)
  self
end

#around_request(callable = nil, &block) ⇒ 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.

Register an around_request callback

Since:

  • 0.1.0



257
258
259
260
# File 'lib/zenrows/client.rb', line 257

def around_request(callable = nil, &block)
  @hooks.register(:around_request, callable, &block)
  self
end

#before_request(callable = nil, &block) ⇒ 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.

Register a before_request callback

Since:

  • 0.1.0



233
234
235
236
# File 'lib/zenrows/client.rb', line 233

def before_request(callable = nil, &block)
  @hooks.register(:before_request, callable, &block)
  self
end

#on_error(callable = nil, &block) ⇒ 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.

Register an on_error callback

Since:

  • 0.1.0



251
252
253
254
# File 'lib/zenrows/client.rb', line 251

def on_error(callable = nil, &block)
  @hooks.register(:on_error, callable, &block)
  self
end

#on_response(callable = nil, &block) ⇒ 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.

Register an on_response callback

Since:

  • 0.1.0



245
246
247
248
# File 'lib/zenrows/client.rb', line 245

def on_response(callable = nil, &block)
  @hooks.register(:on_response, callable, &block)
  self
end