Sha256: 7b263a85d5f2f1e720eb77de457e25ccdfdc8ca96fab56d92db94cd78e046a45

Contents?: true

Size: 907 Bytes

Versions: 4

Compression:

Stored size: 907 Bytes

Contents

module ActiveRecord::Associations::Builder # rubocop:disable Style/ClassAndModuleChildren, Style/FrozenStringLiteralComment
  class HasManyForActiveModel < HasMany
    if ActiveRecord.version >= Gem::Version.new('5.0.0.beta')
      AR_CALLBACK_METHODS = %i[define_callback before_validation after_validation before_save
                               after_save before_update after_update].freeze

      def self.valid_options(_options)
        super + %i[active_model
                   target_ids] - %i[through dependent source source_type counter_cache as]
      end

      def self.define_callbacks(model, reflection)
        return unless AR_CALLBACK_METHODS.all? { |meth| respond_to?(meth) }

        super
      end
    else
      def valid_options
        super + %i[active_model
                   target_ids] - %i[through dependent source source_type counter_cache as]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eac_rails_utils-0.24.0 lib/active_record/associations/builder/has_many_for_active_model.rb
eac_rails_utils-0.23.4 lib/active_record/associations/builder/has_many_for_active_model.rb
eac_rails_utils-0.23.3 lib/active_record/associations/builder/has_many_for_active_model.rb
eac_rails_utils-0.23.2 lib/active_record/associations/builder/has_many_for_active_model.rb