Sha256: ffc6f89caa8ddcca5a9e998b9052385d97cc92937282e9d055a55424e6b25e4d

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

module ActiveRecord::Turntable
  module ActiveRecordExt
    module ActsAsArchiveExt
      def self.prepended(base)
        class << base
          prepend ClassMethods
        end
      end

      module ClassMethods
        # @note use the same shard which `from` shard using
        def move(config, where, merge_options = {})
          if [config[:to], config[:from]].all? { |k| k.try(:turntable_enabled?) }
            current_shard = config[:from].connection.current_shard.name.to_sym
            config[:to].connection.with_shard(current_shard) {
              super
            }
          else
            super
          end
        end
      end
    end

    begin
      require 'acts_as_archive'
      ActsAsArchive.prepend ActsAsArchiveExt
    rescue LoadError
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-turntable-3.0.0.alpha3 lib/active_record/turntable/active_record_ext/acts_as_archive_extension.rb
activerecord-turntable-3.0.0.alpha2 lib/active_record/turntable/active_record_ext/acts_as_archive_extension.rb
activerecord-turntable-3.0.0.alpha1 lib/active_record/turntable/active_record_ext/acts_as_archive_extension.rb