Class: TDL::QueueBasedImplementationRunner::ApplyProcessingRules
- Inherits:
-
Object
- Object
- TDL::QueueBasedImplementationRunner::ApplyProcessingRules
- Defined in:
- lib/tdl/queue/queue_based_implementation_runner.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_response(remote_broker, request, response) ⇒ Object
-
#initialize(processing_rules) ⇒ ApplyProcessingRules
constructor
A new instance of ApplyProcessingRules.
- #prepare_for_next_request(remote_broker, response) ⇒ Object
- #process_next_request_from(remote_broker, request) ⇒ Object
Constructor Details
#initialize(processing_rules) ⇒ ApplyProcessingRules
Returns a new instance of ApplyProcessingRules.
54 55 56 57 58 |
# File 'lib/tdl/queue/queue_based_implementation_runner.rb', line 54 def initialize(processing_rules) @processing_rules = processing_rules @logger = Logging.logger[self] @audit = AuditStream.new end |
Class Method Details
.request_as_object(request) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/tdl/queue/queue_based_implementation_runner.rb', line 94 def self.request_as_object(request) Request.new(request., request.id, request.method, ApplyProcessingRules.to_openstruct(request.params)) end |
.to_openstruct(obj) ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/tdl/queue/queue_based_implementation_runner.rb', line 101 def self.to_openstruct(obj) case obj when Hash OpenStruct.new(obj.transform_values { |v| to_openstruct(v) }) when Array obj.map { |e| to_openstruct(e) } else obj end end |
Instance Method Details
#after_response(remote_broker, request, response) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/tdl/queue/queue_based_implementation_runner.rb', line 78 def after_response(remote_broker, request, response) if response.instance_of? FatalErrorResponse # Do nothing else remote_broker.respond_to(request, response) end end |
#prepare_for_next_request(remote_broker, response) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/tdl/queue/queue_based_implementation_runner.rb', line 86 def prepare_for_next_request(remote_broker, response) if response.instance_of? FatalErrorResponse remote_broker.close else # Do nothing end end |
#process_next_request_from(remote_broker, request) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/tdl/queue/queue_based_implementation_runner.rb', line 61 def process_next_request_from(remote_broker, request) @audit.start_line @audit.log_request(request) # Obtain response from user request_as_object = ApplyProcessingRules.request_as_object(request) response = @processing_rules.get_response_for(request_as_object) @audit.log_response(response) # Act after_response(remote_broker, request, response) @audit.end_line prepare_for_next_request(remote_broker, response) end |