By Jorge Miramontes <jorge.miramontes@rackspace.com> and H. Wade Minter <minter@lunenburg.org>
See COPYING for license information. Copyright © 2012, Rackspace US, Inc.
To begin reviewing the available methods and examples, peruse the README.rodc file, or begin by looking at documentation for the CloudDB::Connection class.
The CloudDB class is the base class. Not much of note aside from housekeeping happens here. To create a new CloudDB connection, use the CloudDB::Connection.new method.
CGI.escape, but without special treatment on spaces
# File lib/clouddb.rb, line 84 def self.escape(str,extra_exclude_chars = '') str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase end end
# File lib/clouddb.rb, line 79 def self.hydra @@hydra ||= Typhoeus::Hydra.new end
# File lib/clouddb.rb, line 90 def self.paginate(options = {}) path_args = [] path_args.push(URI.encode("limit=#{options[:limit]}")) if options[:limit] path_args.push(URI.encode("offset=#{options[:offset]}")) if options[:offset] path_args.join("&") end
Helper method to recursively symbolize hash keys.
# File lib/clouddb.rb, line 45 def self.symbolize_keys(obj) case obj when Array obj.inject([]){|res, val| res << case val when Hash, Array symbolize_keys(val) else val end res } when Hash obj.inject({}){|res, (key, val)| nkey = case key when String key.to_sym else key end nval = case val when Hash, Array symbolize_keys(val) else val end res[nkey] = nval res } else obj end end