Class: MuchRailsPubSub::Subscription
- Inherits:
-
Object
- Object
- MuchRailsPubSub::Subscription
- Defined in:
- lib/much-rails-pub-sub/subscription.rb
Instance Attribute Summary collapse
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(params) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(event_name, job_class:) ⇒ Subscription
constructor
A new instance of Subscription.
Constructor Details
#initialize(event_name, job_class:) ⇒ Subscription
Returns a new instance of Subscription.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 8 def initialize(event_name, job_class:) @event_name = event_name @job_class = job_class unless job_class.respond_to?(:perform_later) raise( ArgumentError, "Invalid job class #{job_class.inspect}: it does not respond to "\ "the :perform_later method.", ) end end |
Instance Attribute Details
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
6 7 8 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 6 def event_name @event_name end |
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
6 7 8 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 6 def job_class @job_class end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 33 def ==(other) if other.is_a?(self.class) event_name == other.event_name && job_class == other.job_class else super end end |
#call(params) ⇒ Object
21 22 23 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 21 def call(params) job_class.perform_later(params) end |
#eql?(other) ⇒ Boolean
29 30 31 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 29 def eql?(other) job_class.eql?(other.job_class) end |
#hash ⇒ Object
25 26 27 |
# File 'lib/much-rails-pub-sub/subscription.rb', line 25 def hash job_class.hash end |