Skip to content

Commit

Permalink
adding more docs for latest patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Sosinski committed Oct 27, 2010
1 parent fe07706 commit 6d19edf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/couch-client.rb
Expand Up @@ -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)
Expand All @@ -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'
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions lib/couch-client/connection_handler.rb
Expand Up @@ -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
Expand Down

0 comments on commit 6d19edf

Please sign in to comment.