Module: Icalia::Event::Subscriber::ClassMethods
- Defined in:
- lib/icalia/event/subscriber.rb
Instance Method Summary collapse
- #auto_subscribe ⇒ Object
- #process(event_class_name, options = {}) ⇒ Object
- #subscribe_to_topic(new_topic_name, options = {}) ⇒ Object
- #subscription_name ⇒ Object
Instance Method Details
#auto_subscribe ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/icalia/event/subscriber.rb', line 43 def auto_subscribe client = Subserver::Pubsub.client topic = client.topic(topic_name) || client.create_topic(topic_name) topic.subscription(subscription_name) || topic.subscribe(subscription_name) end |
#process(event_class_name, options = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/icalia/event/subscriber.rb', line 51 def process(event_class_name, = {}) return unless (processor = .delete(:with)).present? processor_map[event_class_name] = processor end |
#subscribe_to_topic(new_topic_name, options = {}) ⇒ Object
34 35 36 37 |
# File 'lib/icalia/event/subscriber.rb', line 34 def subscribe_to_topic(new_topic_name, = {}) class_variable_set '@@topic_name', new_topic_name .merge(subscription: subscription_name) end |
#subscription_name ⇒ Object
39 40 41 |
# File 'lib/icalia/event/subscriber.rb', line 39 def subscription_name "#{subscription_name_prefix}-#{topic_name}" end |