Sha256: dc5455f2308e587c2343fcaa1b5073f457044e9c9329fde9b84d8a55296099ea

Contents?: true

Size: 726 Bytes

Versions: 41

Compression:

Stored size: 726 Bytes

Contents

module Cucumber
  module WireSupport
    class RequestHandler
      def initialize(connection)
        @connection = connection
        @message = underscore(self.class.name.split('::').last)
      end

      def execute(request_params = nil)
        @connection.call_remote(self, @message, request_params)
      end

      def handle_fail(params)
        raise @connection.exception(params)
      end

      def handle_success(params)
      end

      private

      # Props to Rails
      def underscore(camel_cased_word)
        camel_cased_word.to_s.gsub(/::/, '/').
        gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
        gsub(/([a-z\d])([A-Z])/,'\1_\2').
        tr("-", "_").
        downcase
      end
    end
  end
end

Version data entries

41 entries across 39 versions & 2 rubygems

Version Path
cucumber-1.2.2 lib/cucumber/wire_support/request_handler.rb