Class: BatchKit::Events::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/batch-kit/events.rb

Overview

Records subscription details

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, event, options, callback) ⇒ Subscription

Returns a new instance of Subscription.



29
30
31
32
33
34
# File 'lib/batch-kit/events.rb', line 29

def initialize(source, event, options, callback)
    @source = source
    @event = event
    @raise_on_error = options.fetch(:raise_on_error, true)
    @callback = callback
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



26
27
28
# File 'lib/batch-kit/events.rb', line 26

def callback
  @callback
end

#eventObject (readonly)

Returns the value of attribute event.



26
27
28
# File 'lib/batch-kit/events.rb', line 26

def event
  @event
end

#raise_on_errorObject (readonly)

Returns the value of attribute raise_on_error.



26
27
28
# File 'lib/batch-kit/events.rb', line 26

def raise_on_error
  @raise_on_error
end

#sourceObject (readonly)

Returns the value of attribute source.



26
27
28
# File 'lib/batch-kit/events.rb', line 26

def source
  @source
end

Instance Method Details

#===(obj) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/batch-kit/events.rb', line 37

def ===(obj)
    @source.nil? ||             # Nil source means match any obj
        (@source == obj) ||     # Source is obj
        (@source === obj) ||    # obj is an instance of source class
        (@source.instance_of?(Module) && obj.instance_of?(Class) &&
         obj.include?(@source))   # Source is a module included by obj
end