Sha256: c4daef5cbf5dbfb6ba8b3d01d426fe39fa08fa637df5b8b784b7b26476c03c09

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

module Zoomus
  module Utils
    private
      def argument_error(name)
        name ? ArgumentError.new("You must provide #{name}") : ArgumentError
      end

      def parse_response(http_response)
        response = http_response.parsed_response
        # Mocked response returns a string
        response.kind_of?(Hash) ? response : JSON.parse(response)
      end

      def require_params(params, options)
        params = [params] unless params.is_a? Array
        params.each do |param|
          unless options[param]
            raise argument_error(param.to_s)
            break
          end
        end
      end
  end
end

class Array
  def extract_options!
    last.is_a?(::Hash) ? pop : {}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zoomus-0.0.7 lib/zoomus/utils.rb