Module: Aws::Record

Extended by:
Attributes::ClassMethods, DirtyTracking::DirtyTrackingClassMethods, ItemOperations::ItemOperationsClassMethods, Query::QueryClassMethods, RecordClassMethods, SecondaryIndexes::SecondaryIndexesClassMethods
Includes:
Attributes, DirtyTracking, ItemOperations, Query, SecondaryIndexes
Defined in:
lib/aws-record/record.rb,
lib/aws-record.rb,
lib/aws-record/record/batch.rb,
lib/aws-record/record/query.rb,
lib/aws-record/record/errors.rb,
lib/aws-record/record/version.rb,
lib/aws-record/record/attribute.rb,
lib/aws-record/record/item_data.rb,
lib/aws-record/record/attributes.rb,
lib/aws-record/record/batch_read.rb,
lib/aws-record/record/batch_write.rb,
lib/aws-record/record/table_config.rb,
lib/aws-record/record/transactions.rb,
lib/aws-record/record/dirty_tracking.rb,
lib/aws-record/record/key_attributes.rb,
lib/aws-record/record/item_collection.rb,
lib/aws-record/record/item_operations.rb,
lib/aws-record/record/table_migration.rb,
lib/aws-record/record/buildable_search.rb,
lib/aws-record/record/model_attributes.rb,
lib/aws-record/record/secondary_indexes.rb,
lib/aws-record/record/client_configuration.rb,
lib/aws-record/record/marshalers/map_marshaler.rb,
lib/aws-record/record/marshalers/date_marshaler.rb,
lib/aws-record/record/marshalers/list_marshaler.rb,
lib/aws-record/record/marshalers/time_marshaler.rb,
lib/aws-record/record/marshalers/float_marshaler.rb,
lib/aws-record/record/marshalers/string_marshaler.rb,
lib/aws-record/record/marshalers/boolean_marshaler.rb,
lib/aws-record/record/marshalers/integer_marshaler.rb,
lib/aws-record/record/marshalers/date_time_marshaler.rb,
lib/aws-record/record/marshalers/epoch_time_marshaler.rb,
lib/aws-record/record/marshalers/string_set_marshaler.rb,
lib/aws-record/record/marshalers/numeric_set_marshaler.rb

Overview

Aws::Record is the module you include in your model classes in order to decorate them with the Amazon DynamoDB integration methods provided by this library. Methods you can use are shown below, in sub-modules organized by functionality.

Inheritance Support

Aws Record models can be extended using standard ruby inheritance. The child model must include Aws::Record in their model and the following will be inherited:

See example below to see the feature in action.

Examples:

A class definition using Aws::Record

class MyModel
  include Aws::Record
  string_attr     :uuid,    hash_key: true
  integer_attr    :post_id, range_key: true
  boolean_attr    :is_active
  datetime_attr   :created_at
  string_set_attr :tags
  map_attr        :metadata
end

Inheritance between models

class Animal
  include Aws::Record
  string_attr :name, hash_key: true
  integer_attr :age
end

class Dog < Animal
  include Aws::Record
  boolean_attr :family_friendly
end

dog = Dog.find(name: 'Sunflower')
dog.age = 3
dog.family_friendly = true

Defined Under Namespace

Modules: Attributes, ClientConfiguration, DefaultMarshaler, DirtyTracking, Errors, ItemOperations, Marshalers, Query, RecordClassMethods, SecondaryIndexes, Transactions Classes: Attribute, Batch, BatchRead, BatchWrite, BuildableSearch, ItemCollection, TableConfig, TableMigration

Constant Summary collapse

VERSION =
File.read(File.expand_path('../../../VERSION', __dir__)).strip

Class Method Summary collapse

Methods included from RecordClassMethods

disable_mutation_tracking, enable_mutation_tracking, model_valid?, mutation_tracking_enabled?, provisioned_throughput, set_table_name, table_exists?, table_name

Methods included from Attributes::ClassMethods

atomic_counter, attr, boolean_attr, date_attr, datetime_attr, epoch_time_attr, float_attr, hash_key, integer_attr, list_attr, map_attr, numeric_set_attr, range_key, string_attr, string_set_attr, time_attr

Methods included from ItemOperations::ItemOperationsClassMethods

find, find_all, find_with_opts, tfind_opts, transact_check_expression, transact_find, update

Methods included from Query::QueryClassMethods

build_query, build_scan, query, scan

Methods included from SecondaryIndexes::SecondaryIndexesClassMethods

global_secondary_index, global_secondary_indexes, global_secondary_indexes_for_migration, local_secondary_index, local_secondary_indexes, local_secondary_indexes_for_migration

Methods included from DirtyTracking

#attribute_dirty!, #attribute_dirty?, #attribute_was, #destroyed?, #dirty, #dirty?, #new_record?, #persisted?, #reload!, #rollback!, #rollback_attribute!, #save

Methods included from ItemOperations

#assign_attributes, #delete!, #key_values, #save, #save!, #save_values, #update, #update!

Methods included from Attributes

#initialize, #to_h

Class Method Details

.included(sub_class) ⇒ Object

Usage of Aws::Record requires only that you include this module. This method will then pull in the other default modules.

Examples:

class MyTable
  include Aws::Record
  # Attribute definitions go here...
end


67
68
69
70
71
72
73
74
75
76
# File 'lib/aws-record/record.rb', line 67

def self.included(sub_class)
  sub_class.send(:extend, ClientConfiguration)
  sub_class.send(:extend, RecordClassMethods)
  sub_class.send(:include, Attributes)
  sub_class.send(:include, ItemOperations)
  sub_class.send(:include, DirtyTracking)
  sub_class.send(:include, Query)
  sub_class.send(:include, SecondaryIndexes)
  inherit_track_mutations(sub_class) if Aws::Record.extends_record?(sub_class)
end