class BrowserCrawler::HooksContainer

Constants

VALID_TYPES

Attributes

hooks_container[R]

Public Class Methods

new() click to toggle source
# File lib/browser_crawler/hooks_container.rb, line 10
def initialize
  reset
end

Public Instance Methods

add_hook(method: :run_only_one, type:, hook: nil) click to toggle source
# File lib/browser_crawler/hooks_container.rb, line 23
def add_hook(method: :run_only_one, type:, hook: nil)
  unless VALID_TYPES.include?(type)
    raise Errors::InvalidHooksType.new(invalid_type: type)
  end

  @hooks_container[method][type.to_sym] << hook
end
reset() click to toggle source
# File lib/browser_crawler/hooks_container.rb, line 14
def reset
  @hooks_container = Hash.new { |h, k| h[k] = { each: [],
                                                all: [],
                                                unvisited_links: [],
                                                scan_rules: []} }
end