Sha256: 5bb2e51648d8fa979ddb602868aa989d5cbae917b5277f209c97d8f6e2e72aea
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# -*- encoding: utf-8 -*- module Smoodit class Client class Proxy attr_reader :options, :verb, :path def initialize @verb = :get @keys = [] @ids = {} @options = {} @path = "" end def append(key, id=nil, options={}) @verb = key.to_sym if ["get", "post", "put", "delete"].include? key.to_s @keys << key unless ["get", "post", "put", "delete"].include? key.to_s @ids[key.to_sym] = id if id @options = @options.merge(options) if options end def compose_request # puts "@keys: #{@keys.inspect}" # puts "@ids: #{@ids.inspect}" # puts "@options: #{@options.inspect}" # compose request path @path = @keys.collect do |key| if id = @ids.delete(key.to_sym) "#{key}/#{id}" else key end end.join("/") # puts to_s self end def to_s "#{@verb.to_s.upcase} /#{@path} OPTIONS: #{@options.inspect}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smoodit-0.0.2 | lib/smoodit/client/proxy.rb |
smoodit-0.0.1 | lib/smoodit/client/proxy.rb |