Module: Dynamoid::Document::ClassMethods
- Defined in:
- lib/dynamoid/document.rb
Instance Method Summary (collapse)
-
- (Dynamoid::Document) build(attrs = {})
Initialize a new object.
-
- (Dynamoid::Document) create(attrs = {})
Initialize a new object and immediately save it to the database.
-
- (Dynamoid::Document) create!(attrs = {})
Initialize a new object and immediately save it to the database.
-
- (Boolean) exists?(id)
Does this object exist?.
Instance Method Details
- (Dynamoid::Document) build(attrs = {})
Initialize a new object.
53 54 55 |
# File 'lib/dynamoid/document.rb', line 53 def build(attrs = {}) self.new(attrs) end |
- (Dynamoid::Document) create(attrs = {})
Initialize a new object and immediately save it to the database.
23 24 25 26 27 28 29 |
# File 'lib/dynamoid/document.rb', line 23 def create(attrs = {}) obj = self.new(attrs) obj.run_callbacks(:create) do obj.save end obj end |
- (Dynamoid::Document) create!(attrs = {})
Initialize a new object and immediately save it to the database. Raise an exception if persistence failed.
38 39 40 41 42 43 44 |
# File 'lib/dynamoid/document.rb', line 38 def create!(attrs = {}) obj = self.new(attrs) obj.run_callbacks(:create) do obj.save! end obj end |
- (Boolean) exists?(id)
Does this object exist?
64 65 66 |
# File 'lib/dynamoid/document.rb', line 64 def exists?(id) !! find(id) end |