module OceanDynamo::Attributes::ClassMethods
Class methods
Public Instance Methods
dynamo_schema(table_hash_key=:id, table_range_key=nil, locking: :lock_version, timestamps: [:created_at, :updated_at], **keywords, &block)
click to toggle source
Calls superclass method
# File lib/ocean-dynamo/attributes.rb, line 17 def dynamo_schema(table_hash_key=:id, table_range_key=nil, locking: :lock_version, timestamps: [:created_at, :updated_at], **keywords, &block) self.lock_attribute = locking self.timestamp_attributes = timestamps # Init self.fields = HashWithIndifferentAccess.new attribute(table_hash_key, :string, default: "") self.global_secondary_indexes = Hash.new if table_range_key attribute(table_range_key, :string, default: "") self.validates(table_range_key, presence: true) end timestamp_attributes.each { |name| attribute name, :datetime } if timestamp_attributes attribute(lock_attribute, :integer, default: 0) if locking block.call # Define attribute accessors fields.each { |name, md| define_attribute_accessors(name) } # Return table name super end