Class: TreasureData::Database

Inherits:
Model
  • Object
show all
Defined in:
lib/td/client/model.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#client

Instance Method Summary collapse

Constructor Details

#initialize(client, db_name, tables = nil, count = nil, created_at = nil, updated_at = nil, org_name = nil) ⇒ Database

Returns a new instance of Database.



44
45
46
47
48
49
50
51
# File 'lib/td/client/model.rb', line 44

def initialize(client, db_name, tables=nil, count=nil, created_at=nil, updated_at=nil, org_name=nil)
  super(client)
  @db_name = db_name
  @tables = tables
  @count = count
  @created_at = created_at
  @updated_at = updated_at
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



84
85
86
# File 'lib/td/client/model.rb', line 84

def count
  @count
end

#org_nameObject (readonly)

Returns the value of attribute org_name.



53
54
55
# File 'lib/td/client/model.rb', line 53

def org_name
  @org_name
end

Instance Method Details

#create_item_table(name) ⇒ Object



68
69
70
# File 'lib/td/client/model.rb', line 68

def create_item_table(name)
  @client.create_item_table(@db_name, name)
end

#create_log_table(name) ⇒ Object



64
65
66
# File 'lib/td/client/model.rb', line 64

def create_log_table(name)
  @client.create_log_table(@db_name, name)
end

#created_atObject



86
87
88
# File 'lib/td/client/model.rb', line 86

def created_at
  @created_at && !@created_at.empty? ? Time.parse(@created_at) : nil
end

#deleteObject



76
77
78
# File 'lib/td/client/model.rb', line 76

def delete
  @client.delete_database(@db_name)
end

#nameObject



55
56
57
# File 'lib/td/client/model.rb', line 55

def name
  @db_name
end

#query(q) ⇒ Object



80
81
82
# File 'lib/td/client/model.rb', line 80

def query(q)
  @client.query(@db_name, q)
end

#table(table_name) ⇒ Object



72
73
74
# File 'lib/td/client/model.rb', line 72

def table(table_name)
  @client.table(@db_name, table_name)
end

#tablesObject



59
60
61
62
# File 'lib/td/client/model.rb', line 59

def tables
  update_tables! unless @tables
  @tables
end

#update_tables!Object



94
95
96
# File 'lib/td/client/model.rb', line 94

def update_tables!
  @tables = @client.tables(@db_name)
end

#updated_atObject



90
91
92
# File 'lib/td/client/model.rb', line 90

def updated_at
  @updated_at && !@updated_at.empty? ? Time.parse(@updated_at) : nil
end