Module: MongoODM
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/mongo_odm.rb,
lib/mongo_odm/config.rb,
lib/mongo_odm/cursor.rb,
lib/mongo_odm/errors.rb,
lib/mongo_odm/version.rb,
lib/mongo_odm/criteria.rb,
lib/mongo_odm/document.rb,
lib/mongo_odm/collection.rb,
lib/mongo_odm/document/fields.rb,
lib/mongo_odm/document/indexes.rb,
lib/mongo_odm/document/inspect.rb,
lib/mongo_odm/document/equality.rb,
lib/mongo_odm/document/callbacks.rb,
lib/mongo_odm/document/timestamps.rb,
lib/mongo_odm/document/persistence.rb,
lib/mongo_odm/document/validations.rb,
lib/mongo_odm/document/attribute_methods.rb,
lib/mongo_odm/document/attribute_methods/read.rb,
lib/mongo_odm/document/attribute_methods/dirty.rb,
lib/mongo_odm/document/attribute_methods/query.rb,
lib/mongo_odm/document/attribute_methods/write.rb,
lib/mongo_odm/document/attribute_methods/inspect.rb,
lib/mongo_odm/document/attribute_methods/localization.rb,
lib/mongo_odm/document/validations/uniqueness_validator.rb
Overview
Contains the classes and modules related to the ODM built on top of the basic Mongo client.
Defined Under Namespace
Modules: Document, Errors
Classes: Collection, Config, Criteria, Cursor
Constant Summary
collapse
- VERSION_MAJOR =
"0"
- VERSION_MINOR =
"2"
- VERSION_BUILD =
"20"
- VERSION =
"#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_BUILD}"
Class Method Summary
collapse
Class Method Details
.add_index_class(klass) ⇒ Object
63
64
65
|
# File 'lib/mongo_odm.rb', line 63
def self.add_index_class(klass)
indexed_classes << klass
end
|
.config ⇒ Object
33
34
35
|
# File 'lib/mongo_odm.rb', line 33
def self.config
@_config ||= Config.new
end
|
.config=(value) ⇒ Object
37
38
39
40
|
# File 'lib/mongo_odm.rb', line 37
def self.config=(value)
self.connection = nil
@_config = value.is_a?(Config) ? value : Config.new(value)
end
|
.connection ⇒ Object
21
22
23
|
# File 'lib/mongo_odm.rb', line 21
def self.connection
Thread.current[:mongo_odm_connection] ||= config.connection
end
|
.connection=(value) ⇒ Object
25
26
27
|
# File 'lib/mongo_odm.rb', line 25
def self.connection=(value)
Thread.current[:mongo_odm_connection] = value
end
|
.create_indexes ⇒ Object
59
60
61
|
# File 'lib/mongo_odm.rb', line 59
def self.create_indexes
indexed_classes.each {|klass| klass.create_indexes}
end
|
.database ⇒ Object
29
30
31
|
# File 'lib/mongo_odm.rb', line 29
def self.database
Thread.current[:mongo_odm_database] ||= self.connection.db( config.database )
end
|
.dereference(value) ⇒ Object
51
52
53
|
# File 'lib/mongo_odm.rb', line 51
def self.dereference(value)
value.respond_to?(:dereference) ? value.dereference : value
end
|
.indexed_classes ⇒ Object
55
56
57
|
# File 'lib/mongo_odm.rb', line 55
def self.indexed_classes
@_indexes ||= Set.new
end
|
.instanciate(value) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/mongo_odm.rb', line 42
def self.instanciate(value)
return value if value.is_a?(MongoODM::Document)
if value.is_a?(Hash)
klass = value["_class"] || value[:_class]
return klass.constantize.new(value) if klass
end
value.class.type_cast(value.to_mongo)
end
|