Class: Baza::Driver::Sqlite3::Databases

Inherits:
Object
  • Object
show all
Defined in:
lib/baza/driver/sqlite3/databases.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Databases

Returns a new instance of Databases.



2
3
4
# File 'lib/baza/driver/sqlite3/databases.rb', line 2

def initialize(args)
  @db = args.fetch(:db)
end

Instance Method Details

#[](name) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/baza/driver/sqlite3/databases.rb', line 6

def [](name)
  name = name.to_s
  list.each do |database|
    return database if database.name == name
  end

  raise Baza::Errors::DatabaseNotFound
end

#listObject



15
16
17
18
19
20
21
22
23
# File 'lib/baza/driver/sqlite3/databases.rb', line 15

def list
  ArrayEnumerator.new do |yielder|
    yielder << Baza::Driver::Sqlite3::Database.new(
      name: "Main",
      driver: self,
      db: @db
    )
  end
end