Module: LCBO::CrawlKit::Eventable

Defined in:
lib/lcbo/crawlkit/eventable.rb

Defined Under Namespace

Modules: ClassMethods Classes: Callback

Constant Summary collapse

EVENT_TYPES =
%[
before_request
after_request
before_parse
after_parse ]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object


11
12
13
# File 'lib/lcbo/crawlkit/eventable.rb', line 11

def self.included(mod)
  mod.extend(ClassMethods)
end

Instance Method Details

#fire(event_type) ⇒ Object


15
16
17
18
19
# File 'lib/lcbo/crawlkit/eventable.rb', line 15

def fire(event_type)
  self.class.callbacks.
    select { |callback| callback.is_for?(event_type) }.
    each   { |callback| callback.call_on(self) }
end