Module: ActionSubscriber::DSL
- Included in:
- Base
- Defined in:
- lib/action_subscriber/dsl.rb
Instance Method Summary collapse
- #acknowledge_messages? ⇒ Boolean
- #around_filter(filter_method) ⇒ Object
- #around_filters ⇒ Object
- #at_least_once! ⇒ Object
- #at_most_once! ⇒ Object
-
#exchange_names(*names) ⇒ Object
(also: #exchange)
Explicitly set the name of the exchange.
- #manual_acknowledgement! ⇒ Object
- #no_acknowledgement! ⇒ Object
-
#queue_for(method, queue_name) ⇒ Object
Explicitly set the name of a queue for the given method route.
- #queue_names ⇒ Object
- #remote_application_name(name = nil) ⇒ Object (also: #publisher)
-
#routing_key_for(method, routing_key_name) ⇒ Object
Explicitly set the whole routing key to use for a given method route.
- #routing_key_names ⇒ Object
- #run_action_with_filters(env, action) ⇒ Object
Instance Method Details
#acknowledge_messages? ⇒ Boolean
13 14 15 |
# File 'lib/action_subscriber/dsl.rb', line 13 def !! end |
#around_filter(filter_method) ⇒ Object
17 18 19 |
# File 'lib/action_subscriber/dsl.rb', line 17 def around_filter(filter_method) around_filters << filter_method end |
#around_filters ⇒ Object
21 22 23 |
# File 'lib/action_subscriber/dsl.rb', line 21 def around_filters @_around_filters ||= [] end |
#at_least_once! ⇒ Object
3 4 5 6 |
# File 'lib/action_subscriber/dsl.rb', line 3 def at_least_once! = true around_filter :_at_least_once_filter end |
#at_most_once! ⇒ Object
8 9 10 11 |
# File 'lib/action_subscriber/dsl.rb', line 8 def at_most_once! = true around_filter :_at_most_once_filter end |
#exchange_names(*names) ⇒ Object Also known as: exchange
Explicitly set the name of the exchange
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/action_subscriber/dsl.rb', line 27 def exchange_names(*names) @_exchange_names ||= [] @_exchange_names += names.flatten.map(&:to_s) if @_exchange_names.empty? return [ ::ActionSubscriber.config.default_exchange ] else return @_exchange_names.compact.uniq end end |
#manual_acknowledgement! ⇒ Object
39 40 41 |
# File 'lib/action_subscriber/dsl.rb', line 39 def manual_acknowledgement! = true end |
#no_acknowledgement! ⇒ Object
43 44 45 |
# File 'lib/action_subscriber/dsl.rb', line 43 def no_acknowledgement! = false end |
#queue_for(method, queue_name) ⇒ Object
Explicitly set the name of a queue for the given method route
Ex.
queue_for :created, "derp.derp"
queue_for :updated, "foo.bar"
53 54 55 56 |
# File 'lib/action_subscriber/dsl.rb', line 53 def queue_for(method, queue_name) @_queue_names ||= {} @_queue_names[method] = queue_name end |
#queue_names ⇒ Object
58 59 60 |
# File 'lib/action_subscriber/dsl.rb', line 58 def queue_names @_queue_names ||= {} end |
#remote_application_name(name = nil) ⇒ Object Also known as: publisher
62 63 64 65 |
# File 'lib/action_subscriber/dsl.rb', line 62 def remote_application_name(name = nil) @_remote_application_name = name if name @_remote_application_name end |
#routing_key_for(method, routing_key_name) ⇒ Object
Explicitly set the whole routing key to use for a given method route.
70 71 72 73 |
# File 'lib/action_subscriber/dsl.rb', line 70 def routing_key_for(method, routing_key_name) @_routing_key_names ||= {} @_routing_key_names[method] = routing_key_name end |
#routing_key_names ⇒ Object
75 76 77 |
# File 'lib/action_subscriber/dsl.rb', line 75 def routing_key_names @_routing_key_names ||= {} end |
#run_action_with_filters(env, action) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/action_subscriber/dsl.rb', line 79 def run_action_with_filters(env, action) subscriber_instance = self.new(env) final_block = Proc.new { subscriber_instance.public_send(action) } first_proc = around_filters.reverse.reduce(final_block) do |block, filter| Proc.new { subscriber_instance.send(filter, &block) } end first_proc.call end |