Module: Toy::Couch::DesignDoc::ClassMethods

Defined in:
lib/toy/couch/design_doc.rb

Instance Method Summary collapse

Instance Method Details

#design_docObject



12
13
14
# File 'lib/toy/couch/design_doc.rb', line 12

def design_doc
  @design_doc ||= ::CouchRest::Design.new(default_design_doc)
end

#design_doc_idObject



16
17
18
# File 'lib/toy/couch/design_doc.rb', line 16

def design_doc_id
  "_design/#{design_doc_slug}"
end

#design_doc_slugObject



20
21
22
# File 'lib/toy/couch/design_doc.rb', line 20

def design_doc_slug
  self.to_s
end

#design_doc_uriObject



24
25
26
# File 'lib/toy/couch/design_doc.rb', line 24

def design_doc_uri
  "#{store.client.root}/#{design_doc_id}"
end

#save_design_doc(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.



45
46
47
# File 'lib/toy/couch/design_doc.rb', line 45

def save_design_doc(force = false)
  update_design_doc(force)
end

#save_design_doc!Object

Force the update of the model’s design_doc even if it hasn’t changed.



50
51
52
# File 'lib/toy/couch/design_doc.rb', line 50

def save_design_doc!
  save_design_doc(true)
end

#stored_design_docObject

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.



34
35
36
37
38
# File 'lib/toy/couch/design_doc.rb', line 34

def stored_design_doc
  store.client.get(design_doc_id)
rescue RestClient::ResourceNotFound
  nil
end