Module: Mongorm
- Defined in:
- lib/mongorm.rb,
lib/mongorm/version.rb,
lib/mongorm/criteria.rb,
lib/mongorm/repository.rb,
lib/mongorm/repository/class_methods.rb
Defined Under Namespace
Modules: Errors, Repository
Classes: Criteria
Constant Summary
collapse
- VERSION =
'0.0.4'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.environment ⇒ Object
Returns the value of attribute environment.
8
9
10
|
# File 'lib/mongorm.rb', line 8
def environment
@environment
end
|
Class Method Details
.config ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/mongorm.rb', line 19
def config
config_file = File.join('config', 'mongo.yml')
unless File.exists?(config_file)
raise Errors::ConfigurationError.new('config/mongo.yml does not exist')
end
YAML.load_file(config_file)[environment || "development"]
end
|
.connection ⇒ Object
14
15
16
17
|
# File 'lib/mongorm.rb', line 14
def connection
@connection ||= ::Mongo::Connection.new(config['host'], config['port']).
db(config['database'])
end
|
.register(repository) ⇒ Object
9
10
11
12
|
# File 'lib/mongorm.rb', line 9
def register(repository)
klass = Kernel.const_get(repository.name.sub('Repository', ''))
repository.map_to(klass)
end
|