Module: MongoMapper

Defined in:
lib/novelys_mongo_mapper.rb,
lib/novelys_mongo_mapper/plugins.rb,
lib/novelys_mongo_mapper/document.rb,
lib/novelys_mongo_mapper/plugins/keys.rb,
lib/novelys_mongo_mapper/plugins/clone.rb,
lib/novelys_mongo_mapper/plugins/dirty.rb,
lib/novelys_mongo_mapper/plugins/rails.rb,
lib/novelys_mongo_mapper/dynamic_finder.rb,
lib/novelys_mongo_mapper/finder_options.rb,
lib/novelys_mongo_mapper/plugins/logger.rb,
lib/novelys_mongo_mapper/plugins/inspect.rb,
lib/novelys_mongo_mapper/plugins/equality.rb,
lib/novelys_mongo_mapper/embedded_document.rb,
lib/novelys_mongo_mapper/plugins/callbacks.rb,
lib/novelys_mongo_mapper/plugins/protected.rb,
lib/novelys_mongo_mapper/descendant_appends.rb,
lib/novelys_mongo_mapper/plugins/pagination.rb,
lib/novelys_mongo_mapper/plugins/descendants.rb,
lib/novelys_mongo_mapper/plugins/validations.rb,
lib/novelys_mongo_mapper/plugins/associations.rb,
lib/novelys_mongo_mapper/plugins/identity_map.rb,
lib/novelys_mongo_mapper/plugins/serialization.rb,
lib/novelys_mongo_mapper/plugins/associations/base.rb,
lib/novelys_mongo_mapper/plugins/associations/proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/one_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/collection.rb,
lib/novelys_mongo_mapper/plugins/associations/in_array_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/belongs_to_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/embedded_collection.rb,
lib/novelys_mongo_mapper/plugins/associations/many_embedded_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/many_documents_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/many_polymorphic_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/many_documents_as_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb,
lib/novelys_mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb

Defined Under Namespace

Modules: DescendantAppends, Document, EmbeddedDocument, Finders, Plugins Classes: DocumentNotFound, DocumentNotValid, DynamicFinder, FinderOptions, KeyNotFound, MongoMapperError

Class Method Summary collapse

Class Method Details

.connectionObject



33
34
35
# File 'lib/novelys_mongo_mapper.rb', line 33

def self.connection
  @@connection ||= Mongo::Connection.new
end

.connection=(new_connection) ⇒ Object



38
39
40
# File 'lib/novelys_mongo_mapper.rb', line 38

def self.connection=(new_connection)
  @@connection = new_connection
end

.databaseObject



54
55
56
57
58
59
60
# File 'lib/novelys_mongo_mapper.rb', line 54

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



48
49
50
51
# File 'lib/novelys_mongo_mapper.rb', line 48

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.



73
74
75
# File 'lib/novelys_mongo_mapper.rb', line 73

def self.ensure_index(klass, keys, options={})
  ensured_indexes << {:klass => klass, :keys => keys, :options => options}
end

.ensure_indexes!Object



78
79
80
81
82
83
# File 'lib/novelys_mongo_mapper.rb', line 78

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_indexesObject

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.



63
64
65
# File 'lib/novelys_mongo_mapper.rb', line 63

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.



68
69
70
# File 'lib/novelys_mongo_mapper.rb', line 68

def self.ensured_indexes=(value)
  @@ensured_indexes = value
end

.loggerObject



43
44
45
# File 'lib/novelys_mongo_mapper.rb', line 43

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.



96
97
98
# File 'lib/novelys_mongo_mapper.rb', line 96

def self.normalize_object_id(value)
  value.is_a?(String) ? Mongo::ObjectID.from_string(value) : value
end

.time_classObject

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.



91
92
93
# File 'lib/novelys_mongo_mapper.rb', line 91

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.

Returns:



86
87
88
# File 'lib/novelys_mongo_mapper.rb', line 86

def self.use_time_zone?
  Time.respond_to?(:zone) && Time.zone ? true : false
end