Sha256: e2827d9230270025a77d52dc57e935eec533bde83fc24e58c378b22e12a6ba22

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

module ApiTaster
  class Mapper
    class << self
      def get(path, params = {})
        map_method(:get, path, params)
      end

      def post(path, params = {})
        map_method(:post, path, params)
      end

      def put(path, params = {})
        map_method(:put, path, params)
      end

      def delete(path, params = {})
        map_method(:delete, path, params)
      end

      private

      def map_method(method, path, params)
        route = Route.find_by_verb_and_path(method, path)

        if route.nil?
          Route.obsolete_definitions << {
            :verb   => method,
            :path   => path,
            :params => params
          }
        else
          Route.supplied_params[route[:id]] ||= []
          Route.supplied_params[route[:id]] << ApiTaster.global_params.merge(params)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_taster-0.4.8 lib/api_taster/mapper.rb
api_taster-0.4.7 lib/api_taster/mapper.rb