Module: Dynamodb::AttributeAssignment::ClassMethods

Defined in:
lib/dynamodb/attribute_assignment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribute_definitionsObject (readonly)

Returns the value of attribute attribute_definitions.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def attribute_definitions
  @attribute_definitions
end

#global_indexesObject (readonly)

Returns the value of attribute global_indexes.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def global_indexes
  @global_indexes
end

#hash_keyObject (readonly)

Returns the value of attribute hash_key.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def hash_key
  @hash_key
end

#indexesObject (readonly)

Returns the value of attribute indexes.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def indexes
  @indexes
end

#key_schemaObject (readonly)

Returns the value of attribute key_schema.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def key_schema
  @key_schema
end

#local_indexesObject (readonly)

Returns the value of attribute local_indexes.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def local_indexes
  @local_indexes
end

#range_keyObject (readonly)

Returns the value of attribute range_key.



55
56
57
# File 'lib/dynamodb/attribute_assignment.rb', line 55

def range_key
  @range_key
end

Instance Method Details

#global_index(options) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/dynamodb/attribute_assignment.rb', line 89

def global_index(options)
  @indexes ||= []
  @indexes << define_global_index(options)
  options[:keys].keys.each do |_key|
    define_attribute(
      {
        name: options[:keys][_key][:name],
        type: options[:keys][_key][:type]
      }
    )
  end
end

#key(attr_name, attr_type, options) ⇒ Object



72
73
74
75
76
# File 'lib/dynamodb/attribute_assignment.rb', line 72

def key(attr_name, attr_type, options)
  instance_variable_set("@#{options[:key]}_key", attr_name.to_s)
  define_attribute({ name: attr_name, type: attr_type })
  define_key_schema(attr_name, options[:key])
end

#local_index(options) ⇒ Object



78
79
80
81
82
83
84
85
86
87
# File 'lib/dynamodb/attribute_assignment.rb', line 78

def local_index(options)
  @indexes ||= []
  @indexes << define_local_index(options)
  define_attribute(
    {
      name: options[:key][:name],
      type: options[:key][:type]
    }
  )
end

#table_name(_table_name = nil) ⇒ Object



58
59
60
61
62
# File 'lib/dynamodb/attribute_assignment.rb', line 58

def table_name(_table_name = nil)
  return (@_table_name || name.tableize) if _table_name.nil?

  @_table_name = _table_name.to_s
end

#time_to_live(&block) ⇒ Object



102
103
104
# File 'lib/dynamodb/attribute_assignment.rb', line 102

def time_to_live(&block)
  define_method :schedule_time_to_live, &block
end