Sha256: 42c87929062266b8fdc523df3e6dee869d2b30eedb39050ab6db933ad1f47713

Contents?: true

Size: 694 Bytes

Versions: 1

Compression:

Stored size: 694 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
      
      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

1 entries across 1 versions & 1 rubygems

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