Sha256: 76f11418eec23738d12ea0813b73aaeb046545bad4c899459378feb8da065140

Contents?: true

Size: 723 Bytes

Versions: 10

Compression:

Stored size: 723 Bytes

Contents

module Lucid
  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

10 entries across 10 versions & 1 rubygems

Version Path
lucid-0.3.0 lib/lucid/wire_support/request_handler.rb
lucid-0.2.1 lib/lucid/wire_support/request_handler.rb
lucid-0.2.0 lib/lucid/wire_support/request_handler.rb
lucid-0.1.1 lib/lucid/wire_support/request_handler.rb
lucid-0.1.0 lib/lucid/wire_support/request_handler.rb
lucid-0.0.9 lib/lucid/wire_support/request_handler.rb
lucid-0.0.8 lib/lucid/wire_support/request_handler.rb
lucid-0.0.7 lib/lucid/wire_support/request_handler.rb
lucid-0.0.6 lib/lucid/wire_support/request_handler.rb
lucid-0.0.5 lib/lucid/wire_support/request_handler.rb