Sha256: 7ae1191fba772f0d1c756aae2a76fd6585fa68f0d1a80facc3d8263b04e9f597

Contents?: true

Size: 842 Bytes

Versions: 3

Compression:

Stored size: 842 Bytes

Contents

module ActiveRecord::Associations::Builder
  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)

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

      def self.define_callbacks(model, reflection)
        if AR_CALLBACK_METHODS.all? { |meth| self.respond_to?(meth) }
          super
        end
      end
    else
      def valid_options
        super + [:active_model,
                 :target_ids] - [:through, :dependent, :source, :source_type, :counter_cache, :as]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eac_rails_utils-0.23.1 lib/active_record/associations/builder/has_many_for_active_model.rb
eac_rails_utils-0.23.0 lib/active_record/associations/builder/has_many_for_active_model.rb
eac_rails_utils-0.22.3 lib/active_record/associations/builder/has_many_for_active_model.rb