Module: Low::Mongo::Heroku

Defined in:
lib/low/mongo/heroku.rb

Overview

The ‘Heroku` module provides helper methods for Mongo on Heroku.

Class Method Summary collapse

Class Method Details

.current_remoteObject



8
9
10
11
12
13
14
15
# File 'lib/low/mongo/heroku.rb', line 8

def self.current_remote
  # If a mongodb URI can be extracted from `heroku config`,
  if uri = Mongo::Util.extract_mongodb_uris(`heroku config`).first

    # build a Mongo::Remote with it.
    Mongo::Remote.new(uri)
  end
end

.sync_current_remote(local_database_or_mongo) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/low/mongo/heroku.rb', line 18

def self.sync_current_remote(local_database_or_mongo)
  # If there is a remote Heroku Mongo,
  if remote = Heroku.current_remote

    # sync it to the specified database or Mongo.
    Mongo::Util.sync_from_remote(local_database_or_mongo, remote)
  end
end