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?.
-
- (Object) hash_key
Returns the id field for this class.
-
- (Object) read_capacity
Returns the read_capacity for this table.
-
- (Object) table(options = {})
Set up table options, including naming it whatever you want, setting the id key, and manually overriding read and write capacity.
-
- (Object) write_capacity
Returns the write_capacity for this table.
Instance Method Details
- (Dynamoid::Document) build(attrs = {})
Initialize a new object.
82 83 84 |
# File 'lib/dynamoid/document.rb', line 82 def build(attrs = {}) new(attrs) end |
- (Dynamoid::Document) create(attrs = {})
Initialize a new object and immediately save it to the database.
60 61 62 |
# File 'lib/dynamoid/document.rb', line 60 def create(attrs = {}) new(attrs).tap(&:save) end |
- (Dynamoid::Document) create!(attrs = {})
Initialize a new object and immediately save it to the database. Raise an exception if persistence failed.
71 72 73 |
# File 'lib/dynamoid/document.rb', line 71 def create!(attrs = {}) new(attrs).tap(&:save!) end |
- (Boolean) exists?(id)
Does this object exist?
93 94 95 |
# File 'lib/dynamoid/document.rb', line 93 def exists?(id) !! find(id) end |
- (Object) hash_key
Returns the id field for this class.
49 50 51 |
# File 'lib/dynamoid/document.rb', line 49 def hash_key [:key] || :id end |
- (Object) read_capacity
Returns the read_capacity for this table.
35 36 37 |
# File 'lib/dynamoid/document.rb', line 35 def read_capacity [:read_capacity] || Dynamoid::Config.read_capacity end |
- (Object) table(options = {})
Set up table options, including naming it whatever you want, setting the id key, and manually overriding read and write capacity.
28 29 30 |
# File 'lib/dynamoid/document.rb', line 28 def table( = {}) self. = end |
- (Object) write_capacity
Returns the write_capacity for this table.
42 43 44 |
# File 'lib/dynamoid/document.rb', line 42 def write_capacity [:write_capacity] || Dynamoid::Config.write_capacity end |