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
- #collection ⇒ Object
- #drop_collection ⇒ Object
- #ensure_indexes ⇒ Object
- #open_connection ⇒ Object
- #open_store ⇒ Object
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
#collection ⇒ Object
25 26 27 |
# File 'lib/notificon/mongo_store.rb', line 25 def collection @_collection ||= open_connection[self.class.collection_name] end |
#drop_collection ⇒ Object
29 30 31 32 |
# File 'lib/notificon/mongo_store.rb', line 29 def drop_collection collection.drop @_collection = nil end |
#ensure_indexes ⇒ Object
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_connection ⇒ Object
16 17 18 |
# File 'lib/notificon/mongo_store.rb', line 16 def open_connection @db ||= open_store end |
#open_store ⇒ Object
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 |