lib/couch_potato.rb in couch_potato-0.2.26 vs lib/couch_potato.rb in couch_potato-0.2.27
- old
+ new
@@ -5,31 +5,33 @@
require 'ostruct'
JSON.create_id = 'ruby_class'
-module CouchPotato
- Config = Struct.new(:database_name, :validation_framework).new
- Config.validation_framework = :validatable # default to the validatable gem for validations
+unless defined?(CouchPotato)
+ module CouchPotato
+ Config = Struct.new(:database_name, :validation_framework).new
+ Config.validation_framework = :validatable # default to the validatable gem for validations
- # Returns a database instance which you can then use to create objects and query views. You have to set the CouchPotato::Config.database_name before this works.
- def self.database
- @@__database ||= Database.new(self.couchrest_database)
- end
+ # Returns a database instance which you can then use to create objects and query views. You have to set the CouchPotato::Config.database_name before this works.
+ def self.database
+ @@__database ||= Database.new(self.couchrest_database)
+ end
- # Returns the underlying CouchRest database object if you want low level access to your CouchDB. You have to set the CouchPotato::Config.database_name before this works.
- def self.couchrest_database
- @@__couchrest_database ||= CouchRest.database(full_url_to_database)
- end
+ # Returns the underlying CouchRest database object if you want low level access to your CouchDB. You have to set the CouchPotato::Config.database_name before this works.
+ def self.couchrest_database
+ @@__couchrest_database ||= CouchRest.database(full_url_to_database)
+ end
- private
+ private
- def self.full_url_to_database
- raise('No Database configured. Set CouchPotato::Config.database_name') unless CouchPotato::Config.database_name
- if CouchPotato::Config.database_name.match(%r{https?://})
- CouchPotato::Config.database_name
- else
- "http://127.0.0.1:5984/#{CouchPotato::Config.database_name}"
+ def self.full_url_to_database
+ raise('No Database configured. Set CouchPotato::Config.database_name') unless CouchPotato::Config.database_name
+ if CouchPotato::Config.database_name.match(%r{https?://})
+ CouchPotato::Config.database_name
+ else
+ "http://127.0.0.1:5984/#{CouchPotato::Config.database_name}"
+ end
end
end
end
require File.dirname(__FILE__) + '/core_ext/object'