Module: MongoMapper
- Defined in:
- lib/mongo_mapper.rb,
lib/mongo_mapper/key.rb,
lib/mongo_mapper/dirty.rb,
lib/mongo_mapper/document.rb,
lib/mongo_mapper/callbacks.rb,
lib/mongo_mapper/pagination.rb,
lib/mongo_mapper/validations.rb,
lib/mongo_mapper/associations.rb,
lib/mongo_mapper/mongo_mapper.rb,
lib/mongo_mapper/serialization.rb,
lib/mongo_mapper/dynamic_finder.rb,
lib/mongo_mapper/finder_options.rb,
lib/mongo_mapper/associations/base.rb,
lib/mongo_mapper/embedded_document.rb,
lib/mongo_mapper/associations/proxy.rb,
lib/mongo_mapper/associations/one_proxy.rb,
lib/mongo_mapper/associations/collection.rb,
lib/mongo_mapper/associations/in_array_proxy.rb,
lib/mongo_mapper/serializers/json_serializer.rb,
lib/mongo_mapper/rails_compatibility/document.rb,
lib/mongo_mapper/associations/belongs_to_proxy.rb,
lib/mongo_mapper/associations/many_embedded_proxy.rb,
lib/mongo_mapper/associations/many_documents_proxy.rb,
lib/mongo_mapper/associations/many_polymorphic_proxy.rb,
lib/mongo_mapper/associations/many_documents_as_proxy.rb,
lib/mongo_mapper/rails_compatibility/embedded_document.rb,
lib/mongo_mapper/associations/belongs_to_polymorphic_proxy.rb,
lib/mongo_mapper/associations/many_embedded_polymorphic_proxy.rb
Defined Under Namespace
Modules: Associations, Callbacks, Dirty, Document, EmbeddedDocument, Finders, Pagination, RailsCompatibility, Serialization, Validations
Classes: DocumentNotFound, DocumentNotValid, DynamicFinder, FinderOperator, FinderOptions, Key, KeyNotFound, MongoMapperError, OrderOperator, StaleDocumentError
Class Method Summary
collapse
Class Method Details
.connection ⇒ Object
37
38
39
|
# File 'lib/mongo_mapper.rb', line 37
def self.connection
@@connection ||= Mongo::Connection.new
end
|
.connection=(new_connection) ⇒ Object
42
43
44
|
# File 'lib/mongo_mapper.rb', line 42
def self.connection=(new_connection)
@@connection = new_connection
end
|
58
59
60
61
62
63
64
|
# File 'lib/mongo_mapper.rb', line 58
def self.database
if @@database_name.blank?
raise 'You forgot to set the default database name: MongoMapper.database = "foobar"'
end
@@database ||= MongoMapper.connection.db(@@database_name)
end
|
.database=(name) ⇒ Object
52
53
54
55
|
# File 'lib/mongo_mapper.rb', line 52
def self.database=(name)
@@database = nil
@@database_name = name
end
|
.ensure_index(klass, keys, options = {}) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
87
88
89
|
# File 'lib/mongo_mapper.rb', line 87
def self.ensure_index(klass, keys, options={})
ensured_indexes << {:klass => klass, :keys => keys, :options => options}
end
|
.ensure_indexes! ⇒ Object
92
93
94
95
96
97
|
# File 'lib/mongo_mapper.rb', line 92
def self.ensure_indexes!
ensured_indexes.each do |index|
unique = index[:options].delete(:unique)
index[:klass].collection.create_index(index[:keys], unique)
end
end
|
.ensured_indexes ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
77
78
79
|
# File 'lib/mongo_mapper.rb', line 77
def self.ensured_indexes
@@ensured_indexes ||= []
end
|
.ensured_indexes=(value) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
82
83
84
|
# File 'lib/mongo_mapper.rb', line 82
def self.ensured_indexes=(value)
@@ensured_indexes = value
end
|
47
48
49
|
# File 'lib/mongo_mapper.rb', line 47
def self.logger
connection.logger
end
|
.normalize_object_id(value) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
110
111
112
|
# File 'lib/mongo_mapper.rb', line 110
def self.normalize_object_id(value)
value.is_a?(String) ? Mongo::ObjectID.from_string(value) : value
end
|
.safe_mode ⇒ Object
67
68
69
|
# File 'lib/mongo_mapper.rb', line 67
def self.safe_mode
@@safe_mode ||= false
end
|
.safe_mode=(value) ⇒ Object
72
73
74
|
# File 'lib/mongo_mapper.rb', line 72
def self.safe_mode=(value)
@@safe_mode = value
end
|
.time_class ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
105
106
107
|
# File 'lib/mongo_mapper.rb', line 105
def self.time_class
use_time_zone? ? Time.zone : Time
end
|
.use_time_zone? ⇒ Boolean
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
100
101
102
|
# File 'lib/mongo_mapper.rb', line 100
def self.use_time_zone?
Time.respond_to?(:zone) && Time.zone ? true : false
end
|