Sha256: 4cb74c8cdc5b62e07b1dc9c03e5db02083efecbf999083a81a00074e7550db08

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'ethon/easies/http/actionable'
require 'ethon/easies/http/post'
require 'ethon/easies/http/get'
require 'ethon/easies/http/head'
require 'ethon/easies/http/put'
require 'ethon/easies/http/delete'
require 'ethon/easies/http/patch'
require 'ethon/easies/http/options'

module Ethon
  module Easies

    # This module contains logic about making valid http requests.
    module Http

      # Set specified options in order to make a http request.
      #
      # @example Set options for http request.
      #   easy.http_request("www.google.com", :get, {})
      #
      # @param [ String ] url The url.
      # @param [ String ] action_name The http action name.
      # @param [ Hash ] options The options hash.
      def http_request(url, action_name, options = {})
        fabricate(action_name).new(url, options).setup(self)
      end

      private

      # Return the corresponding action class.
      #
      # @example Return the action.
      #   Action.fabricate(:get)
      #
      # @param [ String ] action_name The action name.
      #
      # @return [ Class ] The action class.
      def fabricate(action_name)
        Ethon::Easies::Http.const_get(action_name.to_s.capitalize)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ethon-0.4.2 lib/ethon/easies/http.rb
ethon-0.4.1 lib/ethon/easies/http.rb