lib/baza/database.rb in baza-0.0.20 vs lib/baza/database.rb in baza-0.0.21

- old
+ new

@@ -9,25 +9,41 @@ @driver = args.fetch(:driver) @name = args.fetch(:name) @name_was = @name end - def tables + def tables(args = {}) + list_args = {database: name} + list_args[:name] = args.fetch(:name) if args[:name] + ArrayEnumerator.new do |yielder| - @db.tables.list(database: name) do |table| + @db.tables.list(list_args) do |table| yielder << table end end end def table(name) - @db.tables[name] + table = tables(name: name).first + raise Baza::Errors::TableNotFound unless table + table end + def table_exists?(name) + table(name) + true + rescue Baza::Errors::TableNotFound + false + end + def save! raise Baza::Errors::NotImplemented end def to_param name + end + + def use(&blk) + @db.databases.with_database(name, &blk) end end