Sha256: 21109d16545ca282d07738708aca6430142f4b383a06e7badf3ba28a4d2daba8

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Mongoid
module Orderable
module Mixins
  module Callbacks
    extend ActiveSupport::Concern

    ORDERABLE_TRANSACTION_KEY = :__mongoid_orderable_in_txn

    included do
      around_save :orderable_update_positions
      after_destroy :orderable_remove_positions, unless: -> { embedded? && _root.destroyed? }

      delegate :update_positions,
               :remove_positions,
               to: :orderable_engine,
               prefix: :orderable

      protected

      def orderable_engine
        @orderable_engine ||= Mongoid::Orderable::Engine.new(self)
      end
    end
  end
end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid_orderable-6.0.1 lib/mongoid/orderable/mixins/callbacks.rb
mongoid_orderable-6.0.0 lib/mongoid/orderable/mixins/callbacks.rb