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
52
# 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
  @org_name = org_name
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



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

def count
  @count
end

#org_nameObject (readonly)

Returns the value of attribute org_name.



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

def org_name
  @org_name
end

Instance Method Details

#create_item_table(name) ⇒ Object



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

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

#create_log_table(name) ⇒ Object



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

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

#created_atObject



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

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

#deleteObject



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

def delete
  @client.delete_database(@db_name)
end

#nameObject



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

def name
  @db_name
end

#query(q) ⇒ Object



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

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

#table(table_name) ⇒ Object



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

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

#tablesObject



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

def tables
  update_tables! unless @tables
  @tables
end

#update_tables!Object



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

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

#updated_atObject



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

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