Class: SequelMigrationsToys::Template::Base

Inherits:
Object
  • Object
show all
Includes:
Toys::Template
Defined in:
lib/sequel_migrations_toys/template/_base.rb

Overview

Base class for templates

Direct Known Subclasses

Check, Disable, Enable, List, Reversion, Rollback, Run

Constant Summary collapse

CommonMigrationsCode =

Module with common code for migrations

Module.new do
	private

	def migration_file_class(db_migrations_dir, db_connection = nil)
		return @migration_file_class if defined? @migration_file_class

		require "#{__dir__}/_migration_file"

		context_directory = self.context_directory
		@migration_file_class = Class.new(MigrationFile) do
			self.root_dir = File.expand_path context_directory
			self.db_migrations_dir = File.expand_path db_migrations_dir
			self.db_connection = db_connection
		end
	end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_migrations_dir:, db_connection_proc:) ⇒ Base

Returns a new instance of Base.



11
12
13
14
# File 'lib/sequel_migrations_toys/template/_base.rb', line 11

def initialize(db_migrations_dir:, db_connection_proc:)
	@db_migrations_dir = db_migrations_dir
	@db_connection_proc = db_connection_proc
end

Instance Attribute Details

#db_connection_procObject (readonly)

Returns the value of attribute db_connection_proc.



9
10
11
# File 'lib/sequel_migrations_toys/template/_base.rb', line 9

def db_connection_proc
  @db_connection_proc
end

#db_migrations_dirObject (readonly)

Returns the value of attribute db_migrations_dir.



9
10
11
# File 'lib/sequel_migrations_toys/template/_base.rb', line 9

def db_migrations_dir
  @db_migrations_dir
end

Instance Method Details

#db_connectionObject



16
17
18
19
20
21
22
23
24
# File 'lib/sequel_migrations_toys/template/_base.rb', line 16

def db_connection
	return @db_connection if defined? @db_connection

	@db_connection = db_connection_proc.call

	# @db_connection.loggers << Logger.new($stdout)

	@db_connection
end