Module: CouchRest::Model::Config
- Extended by:
- Config
- Included in:
- Config
- Defined in:
- lib/couchrest_model_config/model.rb,
lib/couchrest_model_config/config.rb,
lib/couchrest_model_config/server.rb
Defined Under Namespace
Modules: Server
Classes: Model
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(model, *args, &block) ⇒ Object
44
45
46
47
|
# File 'lib/couchrest_model_config/config.rb', line 44
def method_missing(model, *args, &block)
return model_configs(model) unless block
configure_model model, &block
end
|
Instance Method Details
#current_server ⇒ Object
10
11
12
|
# File 'lib/couchrest_model_config/config.rb', line 10
def current_server
Server.send(environment) || Server.default
end
|
#database(*args, &block) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/couchrest_model_config/config.rb', line 22
def database(*args, &block)
if args.empty?
configure_default_database &block
else
args.each {|m| configure_model m, &block}
end
end
|
#default_database ⇒ Object
36
37
38
|
# File 'lib/couchrest_model_config/config.rb', line 36
def default_database
model_configs(:default_database).send(self.environment) || model_configs(:default_database).default
end
|
#edit(&block) ⇒ Object
18
19
20
|
# File 'lib/couchrest_model_config/config.rb', line 18
def edit(&block)
self.instance_eval &block
end
|
#environment(&block) ⇒ Object
6
7
8
|
# File 'lib/couchrest_model_config/config.rb', line 6
def environment(&block)
block ? environment_proc(block) : environment_proc.call
end
|
#for(m) ⇒ Object
40
41
42
|
# File 'lib/couchrest_model_config/config.rb', line 40
def for(m)
model_configs(m)
end
|
#reset ⇒ Object
30
31
32
33
34
|
# File 'lib/couchrest_model_config/config.rb', line 30
def reset
@model_configs = {}
@environment_proc = nil
Server.reset
end
|
#server(&block) ⇒ Object
14
15
16
|
# File 'lib/couchrest_model_config/config.rb', line 14
def server(&block)
block ? Server.instance_eval(&block) : Server
end
|