module TinyDyno::Document
Public Class Methods
new(attrs = nil) { |self| ... }
click to toggle source
Instantiate a new Document
, setting the Document's attributes if given. If no attributes are provided, they will be initialized with an empty Hash
.
The Hash Key must currently be provided from the applicationIf a HashKey
is defined, the document's id will be set to that key,
@example Create a new document.
Person.new(hash_key: hash_key, title: "Sir")
@param [ Hash ] attrs The attributes to set up the document with.
@return [ Document
] A new document. @since 1.0.0
# File lib/tiny_dyno/document.rb, line 30 def initialize(attrs = nil) @new_record = true @attributes ||= {} process_attributes(attrs) do yield(self) if block_given? end # run_callbacks(:initialize) unless _initialize_callbacks.empty? # raise ::TinyDyno::Errors::MissingHashKey.new(self.name) unless @hash_key.is_a?(Hash) end
Public Instance Methods
delete()
click to toggle source
# File lib/tiny_dyno/document.rb, line 40 def delete request_delete end
Private Instance Methods
request_delete()
click to toggle source
# File lib/tiny_dyno/document.rb, line 46 def request_delete request = { table_name: self.class.table_name, key: keys_as_selector } TinyDyno::Adapter.delete_item(request: request) end