From 6d19edf66c4ce9f398b36fe1e4d0cab0e4b140b8 Mon Sep 17 00:00:00 2001 From: Robert Sosinski Date: Tue, 26 Oct 2010 21:32:02 -0400 Subject: [PATCH] adding more docs for latest patch --- lib/couch-client.rb | 10 ++++++---- lib/couch-client/connection_handler.rb | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/couch-client.rb b/lib/couch-client.rb index 78ac594..227e8f2 100644 --- a/lib/couch-client.rb +++ b/lib/couch-client.rb @@ -2,14 +2,16 @@ # The CouchClient module is the overall container of all CouchClient logic. module CouchClient + VERSION = "0.0.1" + begin # Require HashWithIndifferentAccess gem if available. require 'active_support/hash_with_indifferent_access' class Hash < ActiveSupport::HashWithIndifferentAccess private - # Patching `convert_value` method, else it will absorb all "Hashlike" - # objects and convert them into a HashWithIndifferentAccess object. + # objects and convert them into a HashWithIndifferentAccess. + # NOTE: As this is patching a private method, this is probably not a good idea. def convert_value(value) if value.instance_of?(::Hash) # specifying Ruby's Hash, not CouchClient's Hash self.class.new_from_hash_copying_default(value) @@ -25,6 +27,8 @@ def convert_value(value) class Hash < ::Hash; end end + # requiring libraries inside of the CouchClient library so they can use + # HashWithIndifferentAccess instead of Hash if it is available. require 'couch-client/connection' require 'couch-client/connection_handler' require 'couch-client/hookup' @@ -36,8 +40,6 @@ class Hash < ::Hash; end require 'couch-client/collection' require 'couch-client/row' - VERSION = "0.0.1" - class Error < Exception; end # Start using CouchClient by constructing a new CouchClient::Connection object with a Hash: diff --git a/lib/couch-client/connection_handler.rb b/lib/couch-client/connection_handler.rb index 1033d58..aee0ae3 100644 --- a/lib/couch-client/connection_handler.rb +++ b/lib/couch-client/connection_handler.rb @@ -20,6 +20,7 @@ def initialize @port = 5984 end + # Sets the database and ensures that it follows proper naming conventions. def database=(database) if database.match(/^[a-z0-9_$()+-\/]+$/) @database = database