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
45 46 47 48 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 45 def collection assert_supported database.collection(collection_name) end |
#collection_name ⇒ Object
40 41 42 43 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 40 def collection_name assert_supported @collection_name ||= self.to_s.tableize.gsub(/\//, '.') end |
#connection(mongo_connection = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 6 def connection(mongo_connection=nil) assert_supported if mongo_connection.nil? @connection ||= MongoMapper.connection else @connection = mongo_connection end @connection end |
#database ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 26 def database assert_supported if database_name.nil? MongoMapper.database else connection.db(database_name) end end |
#database_name ⇒ Object
21 22 23 24 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 21 def database_name assert_supported @database_name end |
#set_collection_name(name) ⇒ Object
35 36 37 38 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 35 def set_collection_name(name) assert_supported @collection_name = name end |
#set_database_name(name) ⇒ Object
16 17 18 19 |
# File 'lib/mongo_mapper/plugins/persistence.rb', line 16 def set_database_name(name) assert_supported @database_name = name end |