Sha256: 5a5ffa876714c29ce07c34eab99c874a6735625ad7200a448d1a1edd7a84ecf5

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

module ActiveRecord
  module ShardFor
    module Patch
      extend ActiveSupport::Concern

      module ClassMethods
        # For ActiveRecord::Enum patch.
        # See https://github.com/yuemori/activerecord-shard_for/issues/10
        def enum(definitions)
          super
          shard_repository.all.each { |shard| shard.defined_enums = defined_enums }
        end

        # For ActiveSupport::Callbacks patch.
        #
        # Since define_callbacks has not been successfully propagated to the shard class when called,
        # we also call define_callback of the shard class.
        def define_callbacks(*args)
          if abstract_class
            all_shards.each do |model|
              model.define_callbacks(*args)
            end
          end

          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-shard_for-0.7.0 lib/activerecord/shard_for/patch.rb