Method: Rdy#initialize

Defined in:
lib/rdy.rb

#initialize(table, hash_key, range_key = nil) ⇒ Rdy

Returns a new instance of Rdy.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rdy.rb', line 10

def initialize(table, hash_key, range_key = nil)
  @attributes = {}; @table = table.to_s; @hash_key = hash_key[0].to_s
  @range_key = range_key[0].to_s if range_key
  @is_new = true
  self.hash_key_conditional_check = false
  self.check_table_status = false
  if @@_tables[table]
    @_table = @@_tables[table]
  else
    @_table = Rdy.dynamo_db.tables[@table]
    if self.check_table_status
      if @_table.status == :active
        @@_tables[table] = @_table
      else
        raise "Table not active yet!"
      end
    else
      @_table.hash_key = [@hash_key.to_sym, hash_key[1].to_sym]
      @_table.range_key = [@range_key.to_sym, range_key[1].to_sym] if @range_key
    end
  end
end