Sha256: 7c333ef06a09ad3d461f07b4af9bde40a372a9364b72a122547204b53c80f124

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 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)
        JSON.parse(http_response.parsed_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

2 entries across 2 versions & 1 rubygems

Version Path
zoomus-0.0.6 lib/zoomus/utils.rb
zoomus-0.0.5 lib/zoomus/utils.rb