Module: Notificon::MongoStore

Includes:
Mongo
Included in:
NotificationStore, UserStateStore
Defined in:
lib/notificon/mongo_store.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



10
11
12
13
14
# File 'lib/notificon/mongo_store.rb', line 10

def self.included(klass)
  klass.class_eval do
    extend ClassMethods
  end
end

Instance Method Details

#collectionObject



25
26
27
# File 'lib/notificon/mongo_store.rb', line 25

def collection 
  @_collection ||= open_connection[self.class.collection_name]   
end

#drop_collectionObject



29
30
31
32
# File 'lib/notificon/mongo_store.rb', line 29

def drop_collection
  collection.drop
  @_collection = nil
end

#ensure_indexesObject



34
35
36
# File 'lib/notificon/mongo_store.rb', line 34

def ensure_indexes
  self.class.indexes.each do |index| collection.ensure_index(index) end
end

#open_connectionObject



16
17
18
# File 'lib/notificon/mongo_store.rb', line 16

def open_connection
  @db ||= open_store
end

#open_storeObject



20
21
22
23
# File 'lib/notificon/mongo_store.rb', line 20

def open_store
  uri  = URI.parse(Notificon.connection_profile)
  Connection.from_uri(Notificon.connection_profile).db(uri.path.gsub(/^\//, ''))
end