Class: SequelMigrationsToys::Template::Base
- Inherits:
-
Object
- Object
- SequelMigrationsToys::Template::Base
- Includes:
- Toys::Template
- Defined in:
- lib/sequel_migrations_toys/template/_base.rb
Overview
Base class for templates
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. context_directory self.db_migrations_dir = File. db_migrations_dir self.db_connection = db_connection end end end
Instance Attribute Summary collapse
-
#db_connection_proc ⇒ Object
readonly
Returns the value of attribute db_connection_proc.
-
#db_migrations_dir ⇒ Object
readonly
Returns the value of attribute db_migrations_dir.
Instance Method Summary collapse
- #db_connection ⇒ Object
-
#initialize(db_migrations_dir:, db_connection_proc:) ⇒ Base
constructor
A new instance of Base.
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_proc ⇒ Object (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_dir ⇒ Object (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_connection ⇒ Object
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 |