Sha256: 42a9467f607e090c4c910fc7e78e5f14a6be14f8559a3e5c56a8a5565e9ccce3
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
# NOTE: # Alternative to use this helper is to inherit from ActiveRecord::Generators::Base # which provides the #next_migration_number class method that lets #migration_template work as expected # module Rails3::Migration::Assist class << self attr_accessor :rails_root_dir attr_accessor :orm end def self.included(base) #:nodoc: base.extend ClassMethods end def next_migration_number(dirname) #:nodoc: orm = Rails3::Migration::Assist.orm || Rails.configuration.generators.options[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) rescue raise NotImplementedError end module ClassMethods def migration_lookup_at(dirname) #:nodoc: Dir.glob("#{dirname}/[0-9]*_*.rb") end def migration_exists?(dirname, file_name) #:nodoc: migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first end alias_method :first_migration_file, :migration_exists? def latest_migration_file(dirname, file_name) #:nodoc: migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).sort.last end def current_migration_number(dirname) #:nodoc: migration_lookup_at(dirname).collect do |file| File.basename(file).split("_").first.to_i end.max.to_i end def next_migration_number(dirname) #:nodoc: orm = Rails3::Migration::Assist.orm || Rails.configuration.generators.options[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) rescue raise NotImplementedError end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
migration_assist-0.1.9 | lib/migration_assist/class_methods.rb |
migration_assist-0.1.8 | lib/migration_assist/class_methods.rb |