0
unless defined?(Viget::ForeignKeyMigrations)
0
+ module ForeignKeyMigrations
0
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
0
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
0
- module ForeignKeyMigrations #:nodoc:
0
- module VERSION #:nodoc:
0
+ # Returns the version string for the library.
0
- STRING = [MAJOR, MINOR, TINY].join('.')
0
+ # Returns the library path for the module. If any arguments are given,
0
+ # they will be joined to the end of the libray path using
0
+ def self.libpath( *args )
0
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, *args)
0
- module_name = 'ActiveRecord::ConnectionAdapters'
0
- adapter_names = [ 'MysqlAdapter', 'PostgreSQLAdapter', 'SQLiteAdapter', 'SQLite3Adapter' ]
0
+ # Returns the lpath for the module. If any arguments are given,
0
+ # they will be joined to the end of the path using
0
+ def self.path( *args )
0
+ args.empty? ? PATH : ::File.join(PATH, *args)
0
- libdir = File.dirname(__FILE__)
0
+ # Utility method used to rquire all files ending in .rb that lie in the
0
+ # directory below this file that has the same name as the filename passed
0
+ # in. Optionally, a specific _directory_ name can be passed in such that
0
+ # the _filename_ does not have to be equivalent to the directory.
0
+ def self.require_all_libs_relative_to( fname, dir = nil )
0
+ dir ||= ::File.basename(fname, '.*')
0
+ search_me = ::File.expand_path(::File.join(::File.dirname(fname), dir, '**', '*.rb'))
0
+ Dir.glob(search_me).sort.each {|rb| require rb}
0
- adapter_names.each do |name|
0
- filename = name.downcase.sub(/adapter$/, '_adapter')
0
- require "#{module_name.underscore}/#{filename}"
0
- require File.join(libdir, "foreign_key_migrations/database_support")
0
- require File.join(libdir, "foreign_key_migrations/database_support/postgresql_adapter")
0
- require File.join(libdir, "foreign_key_migrations/database_support/sqlite_adapter")
0
+ module_name = 'ActiveRecord::ConnectionAdapters'
0
+ adapter_names = [ 'MysqlAdapter', 'PostgreSQLAdapter', 'SQLiteAdapter', 'SQLite3Adapter' ]
0
+ adapter_names.each do |name|
0
+ filename = name.downcase.sub(/adapter$/, '_adapter')
0
+ require "#{module_name.underscore}/#{filename}"
0
- require File.join(libdir, "foreign_key_migrations/schema_statements")
0
- require File.join(libdir, "foreign_key_migrations/table_definition")
0
- require File.join(libdir, "foreign_key_migrations/foreign_key_definition")
0
+ ForeignKeyMigrations.require_all_libs_relative_to __FILE__
0
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Viget::ForeignKeyMigrations::SchemaStatements)
0
+ ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Viget::ForeignKeyMigrations::TableDefinition)
0
- ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Viget::ForeignKeyMigrations::SchemaStatements)
0
- ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Viget::ForeignKeyMigrations::TableDefinition)
0
- # Enable foreign key migration support for the following databases.
0
- adapter_names.each do |adapter_name|
0
- if module_name.constantize.const_defined?(adapter_name)
0
- adapter = "#{module_name}::#{adapter_name}".constantize
0
- adapter.send(:include, Viget::ForeignKeyMigrations::DatabaseSupport)
0
+ # Enable foreign key migration support for the following databases.
0
+ adapter_names.each do |adapter_name|
0
+ if module_name.constantize.const_defined?(adapter_name)
0
+ adapter = "#{module_name}::#{adapter_name}".constantize
0
+ adapter.send(:include, Viget::ForeignKeyMigrations::DatabaseSupport)
0
\ No newline at end of file
Comments
No one has commented yet.