Sha256: 98c681e5042cadea8a90ceea1714ac9e43c94305bbcbce3fac84a6bcdf0e619a

Contents?: true

Size: 973 Bytes

Versions: 3

Compression:

Stored size: 973 Bytes

Contents

module ActiveRecord::Turntable::ActiveRecordExt
  module Sequencer
    extend ActiveSupport::Concern

    included do
      include DatabaseStatements
      alias_method_chain :prefetch_primary_key?, :turntable
    end

    module DatabaseStatements
      def default_sequence_name(table_name, pk = nil)
        if ActiveRecord::Turntable::Sequencer.has_sequencer?(table_name)
          ActiveRecord::Turntable::Sequencer.sequence_name(table_name, pk)
        else
          super
        end
      end
    end

    def prefetch_primary_key_with_turntable?(table_name = nil)
      ActiveRecord::Turntable::Sequencer.has_sequencer?(table_name)
    end

    def next_sequence_value(sequence_name)
      ActiveRecord::Turntable::Sequencer.sequences[sequence_name].next_sequence_value(sequence_name)
    end

    def current_sequence_value(sequence_name)
      ActiveRecord::Turntable::Sequencer.sequences[sequence_name].current_sequence_value(sequence_name)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-turntable-2.5.0 lib/active_record/turntable/active_record_ext/sequencer.rb
activerecord-turntable-2.4.0 lib/active_record/turntable/active_record_ext/sequencer.rb
activerecord-turntable-2.3.3 lib/active_record/turntable/active_record_ext/sequencer.rb