Class: BrowserCrawler::HooksContainer
- Inherits:
-
Object
- Object
- BrowserCrawler::HooksContainer
- Includes:
- Singleton
- Defined in:
- lib/browser_crawler/hooks_container.rb
Constant Summary collapse
- VALID_TYPES =
%i[each all unvisited_links scan_rules].freeze
Instance Attribute Summary collapse
-
#hooks_container ⇒ Object
readonly
Returns the value of attribute hooks_container.
Instance Method Summary collapse
- #add_hook(method: :run_only_one, type:, hook: nil) ⇒ Object
-
#initialize ⇒ HooksContainer
constructor
A new instance of HooksContainer.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ HooksContainer
Returns a new instance of HooksContainer.
10 11 12 |
# File 'lib/browser_crawler/hooks_container.rb', line 10 def initialize reset end |
Instance Attribute Details
#hooks_container ⇒ Object (readonly)
Returns the value of attribute hooks_container.
21 22 23 |
# File 'lib/browser_crawler/hooks_container.rb', line 21 def hooks_container @hooks_container end |
Instance Method Details
#add_hook(method: :run_only_one, type:, hook: nil) ⇒ Object
23 24 25 26 27 28 29 |
# 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 ⇒ Object
14 15 16 17 18 19 |
# 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 |