Class: TreasureData::Database
Constant Summary collapse
- PERMISSIONS =
[:administrator, :full_access, :import_only, :query_only]
- PERMISSION_LIST_TABLES =
[:administrator, :full_access]
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
- #org_name ⇒ Object readonly
- #permission ⇒ Object readonly
Attributes inherited from Model
Instance Method Summary collapse
- #create_log_table(name) ⇒ true
- #created_at ⇒ Time?
- #delete ⇒ Symbol
-
#initialize(client, db_name, tables = nil, count = nil, created_at = nil, updated_at = nil, org_name = nil, permission = nil) ⇒ Database
constructor
A new instance of Database.
-
#name ⇒ String
Db_name.
- #query(q) ⇒ Job
- #table(table_name) ⇒ Table
- #tables ⇒ Array<Table>
- #update_tables! ⇒ nil
- #updated_at ⇒ Time?
Constructor Details
#initialize(client, db_name, tables = nil, count = nil, created_at = nil, updated_at = nil, org_name = nil, permission = nil) ⇒ Database
Returns a new instance of Database.
72 73 74 75 76 77 78 79 80 |
# File 'lib/td/client/model.rb', line 72 def initialize(client, db_name, tables=nil, count=nil, created_at=nil, updated_at=nil, org_name=nil, =nil) super(client) @db_name = db_name @tables = tables @count = count @created_at = created_at @updated_at = updated_at @permission = .to_sym end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
85 |
# File 'lib/td/client/model.rb', line 85 attr_reader :org_name, :permission, :count |
#org_name ⇒ Object (readonly)
85 86 87 |
# File 'lib/td/client/model.rb', line 85 def org_name @org_name end |
#permission ⇒ Object (readonly)
85 |
# File 'lib/td/client/model.rb', line 85 attr_reader :org_name, :permission, :count |
Instance Method Details
#create_log_table(name) ⇒ true
100 101 102 |
# File 'lib/td/client/model.rb', line 100 def create_log_table(name) @client.create_log_table(@db_name, name) end |
#created_at ⇒ Time?
122 123 124 |
# File 'lib/td/client/model.rb', line 122 def created_at @created_at && !@created_at.empty? ? Time.parse(@created_at) : nil end |
#delete ⇒ Symbol
111 112 113 |
# File 'lib/td/client/model.rb', line 111 def delete @client.delete_database(@db_name) end |
#name ⇒ String
Returns db_name.
88 89 90 |
# File 'lib/td/client/model.rb', line 88 def name @db_name end |
#query(q) ⇒ Job
117 118 119 |
# File 'lib/td/client/model.rb', line 117 def query(q) @client.query(@db_name, q) end |
#table(table_name) ⇒ Table
106 107 108 |
# File 'lib/td/client/model.rb', line 106 def table(table_name) @client.table(@db_name, table_name) end |
#tables ⇒ Array<Table>
93 94 95 96 |
# File 'lib/td/client/model.rb', line 93 def tables update_tables! unless @tables @tables end |
#update_tables! ⇒ nil
132 133 134 135 136 137 138 139 |
# File 'lib/td/client/model.rb', line 132 def update_tables! @tables = @client.tables(@db_name) # provide Table objects with a reference to the parent Database to avoid # requesting the Database information (such as permission) every time @tables.each {|table| table.database = self } end |
#updated_at ⇒ Time?
127 128 129 |
# File 'lib/td/client/model.rb', line 127 def updated_at @updated_at && !@updated_at.empty? ? Time.parse(@updated_at) : nil end |