module Dynamodb::Querying

Public Class Methods

included(base) click to toggle source
# File lib/dynamodb/querying.rb, line 10
def self.included(base)
  base.extend ClassMethods
  base.extend TableActions
end

Public Instance Methods

destroy() click to toggle source
# File lib/dynamodb/querying.rb, line 40
def destroy
  _keys = self.class._key_definitions(@data[hash_key], @data[range_key])
  self.class.delete_item(table_name, _keys)
  true
rescue Aws::DynamoDB::Errors::ServiceError => e
  handle_error(e)
  false
end
save() click to toggle source
# File lib/dynamodb/querying.rb, line 29
def save
  return false unless valid?

  generate_timestamps
  self.class.put_item(table_name, @data)
  true
rescue Aws::DynamoDB::Errors::ServiceError => e
  handle_error(e)
  false
end
update(attributes = {}) click to toggle source
# File lib/dynamodb/querying.rb, line 15
def update(attributes = {})
  # Stringify keys for updated attributes - data consistency
  @data.deep_merge!(attributes.deep_stringify_keys)

  return false unless valid?

  generate_timestamps
  self.class.put_item(table_name, @data)
  true
rescue Aws::DynamoDB::Errors::ServiceError => e
  handle_error(e)
  false
end