Module: CouchRest::Model::DesignDoc::ClassMethods
- Defined in:
- lib/couchrest/model/design_doc.rb
Instance Method Summary collapse
- #design_doc ⇒ Object
- #design_doc_id ⇒ Object
- #design_doc_slug ⇒ Object
- #design_doc_uri(db = database) ⇒ Object
-
#save_design_doc(db = database, force = false) ⇒ Object
Save the design doc onto a target database in a thread-safe way, not modifying the model’s design_doc.
-
#save_design_doc!(db = database) ⇒ Object
Force the update of the model’s design_doc even if it hasn’t changed.
-
#stored_design_doc(db = database) ⇒ Object
Retreive the latest version of the design document directly from the database.
Instance Method Details
#design_doc ⇒ Object
9 10 11 |
# File 'lib/couchrest/model/design_doc.rb', line 9 def design_doc @design_doc ||= ::CouchRest::Design.new(default_design_doc) end |
#design_doc_id ⇒ Object
13 14 15 |
# File 'lib/couchrest/model/design_doc.rb', line 13 def design_doc_id "_design/#{design_doc_slug}" end |
#design_doc_slug ⇒ Object
17 18 19 |
# File 'lib/couchrest/model/design_doc.rb', line 17 def design_doc_slug self.to_s end |
#design_doc_uri(db = database) ⇒ Object
21 22 23 |
# File 'lib/couchrest/model/design_doc.rb', line 21 def design_doc_uri(db = database) "#{db.root}/#{design_doc_id}" end |
#save_design_doc(db = database, force = false) ⇒ Object
Save the design doc onto a target database in a thread-safe way, not modifying the model’s design_doc
See also save_design_doc! to always save the design doc even if there are no changes.
42 43 44 |
# File 'lib/couchrest/model/design_doc.rb', line 42 def save_design_doc(db = database, force = false) update_design_doc(db, force) end |
#save_design_doc!(db = database) ⇒ Object
Force the update of the model’s design_doc even if it hasn’t changed.
47 48 49 |
# File 'lib/couchrest/model/design_doc.rb', line 47 def save_design_doc!(db = database) save_design_doc(db, true) end |
#stored_design_doc(db = database) ⇒ Object
Retreive the latest version of the design document directly from the database. This is never cached and will return nil if the design is not present.
Use this method if you’d like to compare revisions [_rev] which is not stored in the normal design doc.
31 32 33 34 35 |
# File 'lib/couchrest/model/design_doc.rb', line 31 def stored_design_doc(db = database) db.get(design_doc_id) rescue RestClient::ResourceNotFound nil end |