Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Don't define public class methods in class << self blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed May 24, 2010
1 parent c28fd60 commit 4bb2f98
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions lib/dm-migrations/auto_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ def auto_migrate_up!(repository_name = self.repository_name)

def self.include_migration_api
DataMapper.extend(Migrations::SingletonMethods)
DataMapper::Model.send(:include, Migrations::Model)
DataMapper::Repository.send(:include, Migrations::Repository)
[ :Repository, :Model ].each do |name|
DataMapper.const_get(name).send(:include, Migrations.const_get(name))
end
DataMapper::Model.append_extensions(Migrations::Model)
DataMapper::Adapters::AbstractAdapter.descendants.each do |adapter_class|
Adapters.include_migration_api(ActiveSupport::Inflector.demodulize(adapter_class.name))
Expand All @@ -194,25 +195,22 @@ def self.include_migration_api

module Adapters

extend Chainable

class << self

def include_migration_api(const_name)
require auto_migration_extensions(const_name)
def self.include_migration_api(const_name)
require auto_migration_extensions(const_name)
if DataMapper::Migrations.const_defined?(const_name)
adapter = const_get(const_name)
if DataMapper::Migrations.const_defined?(const_name)
adapter.send(:include, migration_module(const_name))
end
rescue LoadError
# Silently ignore the fact that no adapter extensions could be required
# This means that the adapter in use doesn't support migrations
adapter.send(:include, migration_module(const_name))
end
rescue LoadError
# Silently ignore the fact that no adapter extensions could be required
# This means that the adapter in use doesn't support migrations
end

def migration_module(const_name)
DataMapper::Migrations.const_get(const_name)
end
def self.migration_module(const_name)
DataMapper::Migrations.const_get(const_name)
end

class << self
private

# @api private
Expand Down

0 comments on commit 4bb2f98

Please sign in to comment.