Module: Exegesis::Document::InstanceMethods

Defined in:
lib/exegesis/document.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



38
39
40
# File 'lib/exegesis/document.rb', line 38

def == other
  self.id == other.id
end

#idObject



42
43
44
# File 'lib/exegesis/document.rb', line 42

def id
  @attributes['_id']
end

#initialize(hash = {}, db = nil) ⇒ Object



33
34
35
36
# File 'lib/exegesis/document.rb', line 33

def initialize hash={}, db=nil
  super hash
  @database = db
end

#revObject



46
47
48
# File 'lib/exegesis/document.rb', line 46

def rev
  @attributes['_rev']
end

#saveObject



50
51
52
53
54
55
56
57
# File 'lib/exegesis/document.rb', line 50

def save
  set_timestamps if respond_to?(:set_timestamps)
  if self.class.unique_id && id.nil?
    save_with_custom_unique_id
  else
    save_document
  end
end

#update_attributes(attrs = {}) ⇒ Object

Raises:

  • (ArgumentError)


59
60
61
62
63
# File 'lib/exegesis/document.rb', line 59

def update_attributes attrs={}
  raise ArgumentError, 'must include a matching _rev attribute' unless rev == attrs.delete('_rev')
  super attrs
  save
end