Class: LCBO::CrawlKit::Eventable::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/lcbo/crawlkit/eventable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_type, method_name) ⇒ Callback

Returns a new instance of Callback.



37
38
39
40
# File 'lib/lcbo/crawlkit/eventable.rb', line 37

def initialize(event_type, method_name)
  @event_type = event_type.to_sym
  @method_name = method_name.to_sym
end

Instance Attribute Details

#event_typeObject (readonly)

Returns the value of attribute event_type.



35
36
37
# File 'lib/lcbo/crawlkit/eventable.rb', line 35

def event_type
  @event_type
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



35
36
37
# File 'lib/lcbo/crawlkit/eventable.rb', line 35

def method_name
  @method_name
end

Instance Method Details

#call_on(object) ⇒ Object



49
50
51
# File 'lib/lcbo/crawlkit/eventable.rb', line 49

def call_on(object)
  object.send(method_name)
end

#is_for?(event_sym) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
# File 'lib/lcbo/crawlkit/eventable.rb', line 42

def is_for?(event_sym)
  unless EVENT_TYPES.include?(event_sym.to_s)
    raise ArgumentError, "event_type: #{event_sym} is not valid"
  end
  event_type == event_sym.to_sym
end