Class: TeradataCli::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/teradata-cli/dbobject.rb

Direct Known Subclasses

User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, conn) ⇒ Database

Returns a new instance of Database.



207
208
209
210
211
# File 'lib/teradata-cli/dbobject.rb', line 207

def initialize(name, conn)
  @name = name
  @connection = conn
  invalidate_cache
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



213
214
215
# File 'lib/teradata-cli/dbobject.rb', line 213

def name
  @name
end

Instance Method Details

#childrenObject



241
242
243
# File 'lib/teradata-cli/dbobject.rb', line 241

def children
  @children ||= @connection.child_databases(@name)
end

#inspectObject



223
224
225
# File 'lib/teradata-cli/dbobject.rb', line 223

def inspect
  "\#<#{self.class} #{@name}>"
end

#invalidate_cacheObject



215
216
217
218
219
220
221
# File 'lib/teradata-cli/dbobject.rb', line 215

def invalidate_cache
  @parents = nil
  @children = nil
  @tables = nil
  @own_perms = nil
  @total_perms = nil
end

#own_current_permObject Also known as: current_perm



249
250
251
252
# File 'lib/teradata-cli/dbobject.rb', line 249

def own_current_perm
  load_own_perms
  @own_perms.current
end

#own_max_permObject Also known as: max_perm



256
257
258
259
# File 'lib/teradata-cli/dbobject.rb', line 256

def own_max_perm
  load_own_perms
  @own_perms.max
end

#own_peak_permObject Also known as: peak_perm



263
264
265
266
# File 'lib/teradata-cli/dbobject.rb', line 263

def own_peak_perm
  load_own_perms
  @own_perms.peak
end

#ownerObject Also known as: parent



231
232
233
# File 'lib/teradata-cli/dbobject.rb', line 231

def owner
  parents.first
end

#parentsObject



237
238
239
# File 'lib/teradata-cli/dbobject.rb', line 237

def parents
  @parents ||= @connection.parent_databases(@name)
end

#tablesObject



245
246
247
# File 'lib/teradata-cli/dbobject.rb', line 245

def tables
  @tables ||= @connection.tables(@name)
end

#total_current_permObject



275
276
277
278
# File 'lib/teradata-cli/dbobject.rb', line 275

def total_current_perm
  load_total_perms
  @total_perms.current
end

#total_max_permObject



280
281
282
283
# File 'lib/teradata-cli/dbobject.rb', line 280

def total_max_perm
  load_total_perms
  @total_perms.max
end

#total_peak_permObject



285
286
287
288
# File 'lib/teradata-cli/dbobject.rb', line 285

def total_peak_perm
  load_total_perms
  @total_perms.peak
end

#user?Boolean

Returns:

  • (Boolean)


227
228
229
# File 'lib/teradata-cli/dbobject.rb', line 227

def user?
  false
end