Sha256: 33e36b3112f0224d43c21e28aa3baa38bf07ec4155e04ee418a0de04ed6376aa

Contents?: true

Size: 1.05 KB

Versions: 51

Compression:

Stored size: 1.05 KB

Contents

#
# A Dummy service that may be useful for testing (manual or perhaps in automated
# tests), that simply creates the responses you tell it to, after sleeping the
# amount you tell it to. 
#
#    DummyService:
#      type: DummyService
#      priority: 3
#      sleep: 4.5 # seconds
#      responses:
#        - service_type_value: fulltext
#          display_text: foo
#          url: http://google.com
#        - service_type_value: highlighted_link
#          display_text: bar
#          url: http://amazon.com
# 
class DummyService < Service
  attr_accessor :responses, :sleep
  
  def initialize(config = {})
    self.responses = []
    self.sleep = 0
    super
  end
  
  def service_types_generated
    responses.collect {|r| ServiceTypeValue[ r["service_type_value"] ]}.compact.uniq
  end
  
  def handle(request)
    
    ::Kernel.sleep( self.sleep ) if self.sleep
    
    responses.each do |response|   
      request.add_service_response( { :service => self }.merge(response.symbolize_keys ) )
    end
    
    return request.dispatched(self, true)
  end
  
  
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
umlaut-4.1.7 app/service_adaptors/dummy_service.rb
umlaut-4.1.6 app/service_adaptors/dummy_service.rb
umlaut-4.1.5 app/service_adaptors/dummy_service.rb
umlaut-4.1.4 app/service_adaptors/dummy_service.rb
umlaut-4.1.3 app/service_adaptors/dummy_service.rb
umlaut-4.1.2 app/service_adaptors/dummy_service.rb
umlaut-4.1.1 app/service_adaptors/dummy_service.rb
umlaut-4.1.0 app/service_adaptors/dummy_service.rb
umlaut-4.1.0.pre3 app/service_adaptors/dummy_service.rb
umlaut-4.1.0.pre.2 app/service_adaptors/dummy_service.rb
umlaut-4.1.0.pre.alpha.1 app/service_adaptors/dummy_service.rb
umlaut-4.0.3 app/service_adaptors/dummy_service.rb
umlaut-4.0.2 app/service_adaptors/dummy_service.rb
umlaut-4.0.1 app/service_adaptors/dummy_service.rb
umlaut-4.0.0 app/service_adaptors/dummy_service.rb
umlaut-4.0.0.beta5 app/service_adaptors/dummy_service.rb
umlaut-4.0.0.beta4 app/service_adaptors/dummy_service.rb
umlaut-4.0.0.beta3 app/service_adaptors/dummy_service.rb
umlaut-4.0.0.beta2 app/service_adaptors/dummy_service.rb
umlaut-4.0.0.beta1 app/service_adaptors/dummy_service.rb