Class: CouchRest::Mixins::ClassProxy::Proxy
- Inherits:
-
Object
- Object
- CouchRest::Mixins::ClassProxy::Proxy
show all
- Defined in:
- lib/couchrest/mixins/class_proxy.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(klass, database) ⇒ Proxy
Returns a new instance of Proxy.
34
35
36
37
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 34
def initialize(klass, database)
@klass = klass
@database = database
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 47
def method_missing(m, *args, &block)
if has_view?(m)
query = args.shift || {}
view(m, query, *args, &block)
else
super
end
end
|
Instance Method Details
#all(opts = {}, &block) ⇒ Object
58
59
60
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 58
def all(opts = {}, &block)
@klass.all({:database => @database}.merge(opts), &block)
end
|
#all_design_doc_versions ⇒ Object
84
85
86
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 84
def all_design_doc_versions
@klass.all_design_doc_versions(@database)
end
|
#cleanup_design_docs! ⇒ Object
92
93
94
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 92
def cleanup_design_docs!
@klass.cleanup_design_docs!(@database)
end
|
#count(opts = {}, &block) ⇒ Object
62
63
64
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 62
def count(opts = {}, &block)
@klass.all({:database => @database, :raw => true, :limit => 0}.merge(opts), &block)['total_rows']
end
|
#design_doc ⇒ Object
98
99
100
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 98
def design_doc
@klass.design_doc
end
|
#design_doc_fresh ⇒ Object
102
103
104
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 102
def design_doc_fresh
@klass.design_doc_fresh
end
|
#first(opts = {}) ⇒ Object
66
67
68
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 66
def first(opts = {})
@klass.first({:database => @database}.merge(opts))
end
|
70
71
72
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 70
def get(id)
@klass.get(id, @database)
end
|
#has_view?(view) ⇒ Boolean
76
77
78
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 76
def has_view?(view)
@klass.has_view?(view)
end
|
#model_design_doc ⇒ Object
88
89
90
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 88
def model_design_doc
@klass.model_design_doc(@database)
end
|
#new(*args) ⇒ Object
41
42
43
44
45
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 41
def new(*args)
doc = @klass.new(*args)
doc.database = @database
doc
end
|
#refresh_design_doc ⇒ Object
106
107
108
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 106
def refresh_design_doc
@klass.refresh_design_doc_on(@database)
end
|
#save_design_doc ⇒ Object
110
111
112
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 110
def save_design_doc
@klass.save_design_doc_on(@database)
end
|
#view(name, query = {}, &block) ⇒ Object
80
81
82
|
# File 'lib/couchrest/mixins/class_proxy.rb', line 80
def view(name, query={}, &block)
@klass.view(name, {:database => @database}.merge(query), &block)
end
|