Module: CouchRestAdapter::DocumentManagement

Included in:
Base
Defined in:
lib/couch_rest_adapter/document_management.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

UUID_DOC =
'_uuids/?'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



20
21
22
# File 'lib/couch_rest_adapter/document_management.rb', line 20

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#_set_id_and_namespaceObject



41
42
43
44
# File 'lib/couch_rest_adapter/document_management.rb', line 41

def _set_id_and_namespace
  self['_id'] = set_id if self['_id'].blank?
  self['_id'] = self['_id'].namespace_me self.class.namespace
end

#query(opts = {}) ⇒ Object



37
38
39
# File 'lib/couch_rest_adapter/document_management.rb', line 37

def query opts = {}
  CGI.unescape(opts.to_query)
end

#set_idObject

override this method if you want to set your own id



27
28
29
# File 'lib/couch_rest_adapter/document_management.rb', line 27

def set_id
  uuids.first
end

#uuids(opts = {}) ⇒ Object



31
32
33
34
35
# File 'lib/couch_rest_adapter/document_management.rb', line 31

def uuids opts = {}
  uuid_doc = File.join UUID_DOC, query(opts)
  uuids_path = File.join CouchRestAdapter::Base.base_path, uuid_doc
  CouchRest.get( uuids_path )["uuids"]
end