Module: MongoMapper::Plugins::Persistence::ClassMethods
- Defined in:
- lib/mongo_mapper/plugins/persistence.rb
Instance Method Summary collapse
- #collection ⇒ Object
- #collection_name ⇒ Object
- #connection(mongo_connection = nil) ⇒ Object
- #database ⇒ Object
- #database_name ⇒ Object
- #set_collection_name(name) ⇒ Object
- #set_database_name(name) ⇒ Object
Instance Method Details
#collection ⇒ Object
47 48 49 50 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 47 def collection assert_supported database.collection(collection_name) end |
#collection_name ⇒ Object
42 43 44 45 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 42 def collection_name assert_supported @collection_name ||= self.to_s.tableize.gsub(/\//, '.') end |
#connection(mongo_connection = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 8 def connection(mongo_connection=nil) assert_supported if mongo_connection.nil? @connection ||= MongoMapper.connection else @connection = mongo_connection end @connection end |
#database ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 28 def database assert_supported if database_name.nil? MongoMapper.database else connection.db(database_name) end end |
#database_name ⇒ Object
23 24 25 26 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 23 def database_name assert_supported @database_name end |
#set_collection_name(name) ⇒ Object
37 38 39 40 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 37 def set_collection_name(name) assert_supported @collection_name = name end |
#set_database_name(name) ⇒ Object
18 19 20 21 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 18 def set_database_name(name) assert_supported @database_name = name end |