Class: CouchPotato::View::ViewQuery
- Inherits:
-
Object
- Object
- CouchPotato::View::ViewQuery
- Defined in:
- lib/couch_potato/view/view_query.rb
Overview
Used to query views (and create them if they don’t exist). Usually you won’t have to use this class directly. Instead it is used internally by the CouchPotato::Database.view method.
Instance Method Summary collapse
-
#initialize(couchrest_database, design_document_name, view, list = nil) ⇒ ViewQuery
constructor
A new instance of ViewQuery.
- #query_view!(parameters = {}) ⇒ Object
Constructor Details
#initialize(couchrest_database, design_document_name, view, list = nil) ⇒ ViewQuery
Returns a new instance of ViewQuery.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/couch_potato/view/view_query.rb', line 17 def initialize(couchrest_database, design_document_name, view, list = nil) @database = couchrest_database @design_document_name = design_document_name @view_name = view.keys[0] @map_function = view.values[0][:map] @reduce_function = view.values[0][:reduce] if list @list_function = list.values[0] @list_name = list.keys[0] end end |
Instance Method Details
#query_view!(parameters = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/couch_potato/view/view_query.rb', line 29 def query_view!(parameters = {}) update_view unless CouchPotato::bypass_view_creation || view_has_been_updated? begin query_view parameters rescue RestClient::ResourceNotFound update_view retry end end |