Module: Dynamoid::Document
- Extended by:
- ActiveSupport::Concern
- Includes:
- Components
- Defined in:
- lib/dynamoid/document.rb
Overview
This is the base module for all domain objects that need to be persisted to the database as documents.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary
Attributes included from Persistence
Attributes included from Fields
Instance Method Summary (collapse)
-
- (Object) ==(other)
An object is equal to another object if their ids are equal.
-
- (Dynamoid::Document) initialize(attrs = {})
Initialize a new object.
-
- (Dynamoid::Document) reload
Reload an object from the database -- if you suspect the object has changed in the datastore and you need those changes to be reflected immediately, you would call this method.
Methods included from Validations
Methods included from Persistence
#delete, #destroy, #dump, #persisted?, #save
Methods included from Indexes
#delete_indexes, #save_indexes
Methods included from Fields
#read_attribute, #update_attribute, #update_attributes, #write_attribute
Instance Method Details
- (Object) ==(other)
An object is equal to another object if their ids are equal.
89 90 91 92 |
# File 'lib/dynamoid/document.rb', line 89 def ==(other) return false if other.nil? other.respond_to?(:id) && other.id == self.id end |
- (Dynamoid::Document) initialize(attrs = {})
Initialize a new object.
76 77 78 79 80 81 82 83 84 |
# File 'lib/dynamoid/document.rb', line 76 def initialize(attrs = {}) @new_record = true @attributes ||= {} incoming_attributes = self.class.undump(attrs) self.class.attributes.keys.each do |attribute| send "#{attribute}=", incoming_attributes[attribute] end end |
- (Dynamoid::Document) reload
Reload an object from the database -- if you suspect the object has changed in the datastore and you need those changes to be reflected immediately, you would call this method.
100 101 102 103 |
# File 'lib/dynamoid/document.rb', line 100 def reload self.attributes = self.class.find(self.id).attributes self end |