Class: ActionDispatch::Session::MongoStore

Inherits:
AbstractStore
  • Object
show all
Defined in:
lib/rails_mongo_sessions/mongo_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ MongoStore

Returns a new instance of MongoStore.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_mongo_sessions/mongo_store.rb', line 8

def initialize(app, options = {})
  require 'mongo'
  
  unless options[:collection]
    raise "To avoid creating multiple connections to MongoDB, " +
          "the Mongo Session Store will not create it's own connection" +
          "to MongoDB - you must pass in a collection with the :collection option"
  end
  
  @collection = options[:collection].respond_to?(:call) ? options[:collection].call : options[:collection]
  
  super
end

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



6
7
8
# File 'lib/rails_mongo_sessions/mongo_store.rb', line 6

def collection
  @collection
end