Sha256: 51e7ccbb251982682753c020dc233bedcbd01488ff1600602c4d4979713d2a45
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
class Baza::Database include Baza::DatabaseModelFunctionality attr_reader :db, :driver, :name def initialize(args) @changes = {} @db = args.fetch(:db) @driver = args.fetch(:driver) @name = args.fetch(:name) @name_was = @name end def import_file!(path, args = {}) File.open(path, "r") do |io| use do Baza::Commands::Importer.new({db: @db, io: io}.merge(args)).execute end end end def name=(new_name) @changes[:name] = new_name @name = new_name end def name_changed? @changes.key?(:name) && @changes.fetch(:name).to_s != name.to_s end def name_was @changes[:name] end def tables(args = {}) list_args = {database: name} list_args[:name] = args.fetch(:name) if args[:name] ArrayEnumerator.new do |yielder| @db.tables.list(list_args) do |table| yielder << table end end end def table(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
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
baza-0.0.33 | lib/baza/database.rb |
baza-0.0.32 | lib/baza/database.rb |
baza-0.0.31 | lib/baza/database.rb |
baza-0.0.30 | lib/baza/database.rb |
baza-0.0.29 | lib/baza/database.rb |