Class: MuchRailsPubSub::Config
- Inherits:
-
Object
- Object
- MuchRailsPubSub::Config
- Defined in:
- lib/much-rails-pub-sub.rb
Defined Under Namespace
Classes: DefaultPublishedEvents, PublishedEvents, Subscriptions
Constant Summary collapse
- TestingPublishedEvents =
Class.new(PublishedEvents)
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#publish_job ⇒ Object
Returns the value of attribute publish_job.
-
#publish_job_class ⇒ Object
readonly
Returns the value of attribute publish_job_class.
-
#published_events ⇒ Object
Returns the value of attribute published_events.
-
#publisher_class ⇒ Object
Returns the value of attribute publisher_class.
Instance Method Summary collapse
- #constantize_job(value, type:) ⇒ Object
- #constantize_publish_job_class ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #publish_job_class?(job_class) ⇒ Boolean
- #subscriptions ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
62 63 64 65 |
# File 'lib/much-rails-pub-sub.rb', line 62 def initialize @published_events = DefaultPublishedEvents.new @publisher_class = MuchRailsPubSub::ActiveJobPublisher end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
60 61 62 |
# File 'lib/much-rails-pub-sub.rb', line 60 def logger @logger end |
#publish_job ⇒ Object
Returns the value of attribute publish_job.
60 61 62 |
# File 'lib/much-rails-pub-sub.rb', line 60 def publish_job @publish_job end |
#publish_job_class ⇒ Object (readonly)
Returns the value of attribute publish_job_class.
59 60 61 |
# File 'lib/much-rails-pub-sub.rb', line 59 def publish_job_class @publish_job_class end |
#published_events ⇒ Object
Returns the value of attribute published_events.
60 61 62 |
# File 'lib/much-rails-pub-sub.rb', line 60 def published_events @published_events end |
#publisher_class ⇒ Object
Returns the value of attribute publisher_class.
60 61 62 |
# File 'lib/much-rails-pub-sub.rb', line 60 def publisher_class @publisher_class end |
Instance Method Details
#constantize_job(value, type:) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/much-rails-pub-sub.rb', line 80 def constantize_job(value, type:) begin value.to_s.constantize rescue NameError raise TypeError, "Unknown #{type} job class: #{value.inspect}." end end |
#constantize_publish_job_class ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/much-rails-pub-sub.rb', line 67 def constantize_publish_job_class @publish_job_class = constantize_job(publish_job, type: :publish).tap do |job_class| unless publish_job_class?(job_class) raise( TypeError, "Publish job classes must mixin MuchRailsPubSub::PublishJob. "\ "The given job class, #{job_class.inspect}, does not.", ) end end end |
#publish_job_class?(job_class) ⇒ Boolean
92 93 94 |
# File 'lib/much-rails-pub-sub.rb', line 92 def publish_job_class?(job_class) !!(job_class < MuchRailsPubSub::PublishJobBehaviors) end |
#subscriptions ⇒ Object
88 89 90 |
# File 'lib/much-rails-pub-sub.rb', line 88 def subscriptions @subscriptions ||= Subscriptions.new end |