Sha256: 3dd721a903e7f0011c4b21374c1bfb4a3e2a40657d59a33b2db5115aeacfbcf7

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

module AlsoMigrate
  module Base
    
    def self.included(base)
      unless base.respond_to?(:also_migrate)
        base.extend ClassMethods
      end
    end
    
    module ClassMethods
      
      def also_migrate(*args)
        options = args.extract_options!
        @also_migrate_config ||= []
        @also_migrate_config << {
          :table_name => self.table_name,
          :tables => args.collect(&:to_s),
          :options => {
            :add => options[:add] ? options[:add] : [],
            :subtract => [ options[:subtract] ].flatten.compact,
            :ignore => [ options[:ignore] ].flatten.compact,
            :indexes => options[:indexes] ? [ options[:indexes] ].flatten : nil
          }
        }
        self.class_eval do
          class <<self
            attr_accessor :also_migrate_config
          end
        end
        ::AlsoMigrate.classes ||= []
        ::AlsoMigrate.classes << self
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
also_migrate-0.3.4 lib/also_migrate/base.rb
also_migrate-0.3.3 lib/also_migrate/base.rb
also_migrate-0.3.2 lib/also_migrate/base.rb
also_migrate-0.2.3 lib/also_migrate/base.rb