module AWS::Record

AWS::Record is an ORM built on top of AWS services.

Constants

Base

for backwards compatability with the old AWS::Record::Base

Public Class Methods

as_array(value) click to toggle source

A utility method for casting values into an array.

  • nil is returned as an empty array, []

  • Arrays are returned unmodified

  • Everything else is returned as the sole element of an array

@param [Object] value @return [Array] The value cast into an array @private

# File lib/aws/record.rb, line 91
def self.as_array value
  case value
  when nil   then []
  when Set   then value.to_a
  when Array then value
  else [value]
  end
end
as_set(value) click to toggle source

A utility method for casting values into

  • Sets are returned unmodified

  • everything else is passed through #{::as_array} and then into a new Set

@param [Object] value @return [Set] The value cast into a Set. @private

# File lib/aws/record.rb, line 108
def self.as_set value
  case value
  when Set then value
  else Set.new(as_array(value))
  end
end
domain_prefix() click to toggle source

@return [String,nil] The string that is prepended to all domain names.

# File lib/aws/record.rb, line 51
def self.domain_prefix
  @domain_prefix
end
domain_prefix=(prefix) click to toggle source

Sets a prefix to be applied to all SimpleDB domains associated with AWS::Record::Base classes.

AWS::Record.domain_prefix = 'production_'

class Product < AWS::Record::Base
  set_shard_name 'products'
end

p = Product.new
p.shard #=> 'products'
p.save # the product is persisted to the 'production-products' domain

@param [String] A prefix to append to all domains. This is useful for

grouping domains used by one application with a single prefix.
# File lib/aws/record.rb, line 46
def self.domain_prefix= prefix
  @domain_prefix = prefix
end
table_prefix() click to toggle source

@return [String,nil] The string that is prepended to all table names.

# File lib/aws/record.rb, line 78
def self.table_prefix
  @table_prefix
end
table_prefix=(prefix) click to toggle source

Sets a prefix to be applied to all DynamoDB tables associated with {AWS::Record::HashModel} and {AWS::Record::ListModel} classes.

AWS::Record.table_prefix = 'production_'

class Product < AWS::Record::HashModel
  set_shard_name 'products'
end

p = Product.new
p.shard #=> 'products'
p.save # the product is persisted to the 'production-products' table

@param [String] A prefix to append to all tables. This is

useful for grouping tables used by one application with a
single prefix.
# File lib/aws/record.rb, line 73
def self.table_prefix= prefix
  @table_prefix = prefix
end