Module: Dynamoid::Loadable
Instance Method Summary collapse
- #load(attrs) ⇒ Object
-
#reload ⇒ Dynamoid::Document
Reload an object from the database – if you suspect the object has changed in the data store and you need those changes to be reflected immediately, you would call this method.
Instance Method Details
#load(attrs) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dynamoid/loadable.rb', line 7 def load(attrs) attrs.each do |key, value| send(:"#{key}=", value) if respond_to?(:"#{key}=") end self end |
#reload ⇒ Dynamoid::Document
Reload an object from the database – if you suspect the object has changed in the data store and you need those changes to be reflected immediately, you would call this method. This is a consistent read.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dynamoid/loadable.rb', line 21 def reload = { consistent_read: true } if self.class.range_key [:range_key] = range_value end self.attributes = self.class.find(hash_key, **).attributes @associations.each_value(&:reset) @new_record = false self end |