Module: Exegesis::Document::InstanceMethods
- Defined in:
- lib/exegesis/document.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #id ⇒ Object
- #initialize(hash = {}, db = nil) ⇒ Object
- #rev ⇒ Object
- #save ⇒ Object
- #update_attributes(attrs = {}) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/exegesis/document.rb', line 38 def == other self.id == other.id end |
#id ⇒ Object
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 |
#rev ⇒ Object
46 47 48 |
# File 'lib/exegesis/document.rb', line 46 def rev @attributes['_rev'] end |
#save ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/exegesis/document.rb', line 50 def save 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
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 |