module Tinybucket::Api::Helper::ApiHelper

Private Instance Methods

build_path(base_path, *components) click to toggle source
# File lib/tinybucket/api/helper/api_helper.rb, line 24
def build_path(base_path, *components)
  components.reduce(base_path) do |path, component|
    part = if component.is_a?(Array)
             urlencode(*component)
           else
             component.to_s
           end
    path + '/' + part
  end
rescue ArgumentError => e
  raise ArgumentError, "Failed to build request URL: #{e}"
end
next_proc(method, options) click to toggle source
# File lib/tinybucket/api/helper/api_helper.rb, line 9
def next_proc(method, options)
  lambda do |next_options|
    send(method, options.merge(next_options))
  end
end
urlencode(v, key) click to toggle source
# File lib/tinybucket/api/helper/api_helper.rb, line 15
def urlencode(v, key)
  if v.blank? || (escaped = CGI.escape(v.to_s)).blank?
    msg = "Invalid #{key} parameter. (#{v})"
    raise ArgumentError, msg
  end

  escaped
end