Module: Combi::Service
- Defined in:
- lib/combi/service.rb
Instance Method Summary collapse
- #actions ⇒ Object
- #async_response(&block) ⇒ Object
- #enable(*services) {|block| ... } ⇒ Object
- #fast_actions ⇒ Object
- #no_response ⇒ Object
- #register_actions ⇒ Object
- #service_bus ⇒ Object
- #setup(service_bus, context) ⇒ Object
- #setup_context(context) ⇒ Object
- #setup_services ⇒ Object
Instance Method Details
#actions ⇒ Object
41 42 43 |
# File 'lib/combi/service.rb', line 41 def actions [] end |
#async_response(&block) ⇒ Object
37 38 39 |
# File 'lib/combi/service.rb', line 37 def async_response(&block) lambda &block end |
#enable(*services) {|block| ... } ⇒ Object
53 54 55 56 |
# File 'lib/combi/service.rb', line 53 def enable(*services, &block) service_bus.enable(services) yield block if block_given? end |
#fast_actions ⇒ Object
45 46 47 |
# File 'lib/combi/service.rb', line 45 def fast_actions [] end |
#no_response ⇒ Object
33 34 35 |
# File 'lib/combi/service.rb', line 33 def no_response nil end |
#register_actions ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/combi/service.rb', line 24 def register_actions actions.each do |handler| service_bus.respond_to(self, handler) end fast_actions.each do |handler| service_bus.respond_to(self, handler, fast: true) end end |
#service_bus ⇒ Object
49 50 51 |
# File 'lib/combi/service.rb', line 49 def service_bus @service_bus end |
#setup(service_bus, context) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/combi/service.rb', line 4 def setup(service_bus, context) context ||= {} context[:service_bus] = service_bus setup_context(context) setup_services register_actions end |
#setup_context(context) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/combi/service.rb', line 12 def setup_context(context) @context = context @context.keys.each do |context_var| define_singleton_method context_var do @context[context_var] end end end |
#setup_services ⇒ Object
21 22 |
# File 'lib/combi/service.rb', line 21 def setup_services end |