Sha256: b2f237223ea0b744fdb99d9a7cef4e00de20e79617f475538e509bdded5b141a

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

require 'couchrest'
require 'json'
require 'json/add/core'
require 'json/add/rails'

require 'ostruct'

JSON.create_id = 'ruby_class'

module CouchPotato
  Config = Struct.new(:database_name).new

  # 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

  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}"
    end
  end
end

require File.dirname(__FILE__) + '/core_ext/object'
require File.dirname(__FILE__) + '/core_ext/time'
require File.dirname(__FILE__) + '/core_ext/date'
require File.dirname(__FILE__) + '/core_ext/string'
require File.dirname(__FILE__) + '/core_ext/symbol'
require File.dirname(__FILE__) + '/couch_potato/persistence'

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
couch_potato-0.2.22 lib/couch_potato.rb
couch_potato-0.2.21 lib/couch_potato.rb
couch_potato-0.2.20 lib/couch_potato.rb
couch_potato-0.2.19 lib/couch_potato.rb
couch_potato-0.2.18 lib/couch_potato.rb
couch_potato-0.2.17 lib/couch_potato.rb
couch_potato-0.2.16 lib/couch_potato.rb
couch_potato-0.2.15 lib/couch_potato.rb
couch_potato-0.2.14 lib/couch_potato.rb
couch_potato-0.2.13 lib/couch_potato.rb