Class: LCBO::CrawlKit::Eventable::Callback
- Inherits:
-
Object
- Object
- LCBO::CrawlKit::Eventable::Callback
- Defined in:
- lib/lcbo/crawlkit/eventable.rb
Instance Attribute Summary collapse
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
- #call_on(object) ⇒ Object
-
#initialize(event_type, method_name) ⇒ Callback
constructor
A new instance of Callback.
- #is_for?(event_sym) ⇒ Boolean
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_type ⇒ Object (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_name ⇒ Object (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
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 |