Class: Workling::Routing::ClassAndMethodRouting
- Defined in:
- lib/workling/routing/class_and_method_routing.rb
Class Method Summary collapse
-
.queue_for(clazz, method) ⇒ Object
returns the routing string, given a class and method.
Instance Method Summary collapse
-
#initialize(*args) ⇒ ClassAndMethodRouting
constructor
initializes and builds routing hash.
-
#method_name(queue) ⇒ Object
returns the worker method name, given the routing string.
-
#queue_for(clazz, method) ⇒ Object
returns the routing string, given a class and method.
-
#queue_names ⇒ Object
returns all routed.
-
#queue_names_routing_class(clazz) ⇒ Object
dare you to remove this! go on!.
Constructor Details
#initialize(*args) ⇒ ClassAndMethodRouting
initializes and builds routing hash.
9 10 11 12 13 |
# File 'lib/workling/routing/class_and_method_routing.rb', line 9 def initialize(*args) super build end |
Class Method Details
.queue_for(clazz, method) ⇒ Object
returns the routing string, given a class and method.
26 27 28 29 30 |
# File 'lib/workling/routing/class_and_method_routing.rb', line 26 def self.queue_for(clazz, method) # this is lifted from the Rails constantize method clazz = Object.module_eval("::#{clazz}") unless clazz.is_a?(Class) clazz.queue_for method end |
Instance Method Details
#method_name(queue) ⇒ Object
returns the worker method name, given the routing string.
16 17 18 |
# File 'lib/workling/routing/class_and_method_routing.rb', line 16 def method_name(queue) self[queue].method_for(queue) end |
#queue_for(clazz, method) ⇒ Object
returns the routing string, given a class and method. delegating.
21 22 23 |
# File 'lib/workling/routing/class_and_method_routing.rb', line 21 def queue_for(clazz, method) ClassAndMethodRouting.queue_for(clazz, method) end |
#queue_names ⇒ Object
returns all routed
33 34 35 |
# File 'lib/workling/routing/class_and_method_routing.rb', line 33 def queue_names self.keys end |
#queue_names_routing_class(clazz) ⇒ Object
dare you to remove this! go on!
38 39 40 |
# File 'lib/workling/routing/class_and_method_routing.rb', line 38 def queue_names_routing_class(clazz) self.select { |x, y| y.is_a?(clazz) }.map { |x, y| x } end |