Sha256: 464b795fc7e57ea4fb6be0fbb847da3289ab05e0ba7f61a9a37159a14dacda4f

Contents?: true

Size: 899 Bytes

Versions: 17

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

# This custom association approach is only available in Rails 4.1-5.1. This
# behaviour is superseded by OverriddenReflection for Rails 5.2, and was
# preceded by ScopedReflection for Rails 4.0.
class ThinkingSphinx::ActiveRecord::Depolymorph::AssociationReflection <
  ThinkingSphinx::ActiveRecord::Depolymorph::BaseReflection

  # Since Rails 4.2, the macro argument has been removed. The underlying
  # behaviour remains the same, though.
  def call
    if explicit_macro?
      klass.new name, nil, options, reflection.active_record
    else
      klass.new reflection.macro, name, nil, options, reflection.active_record
    end
  end

  private

  def explicit_macro?
    ActiveRecord::Reflection::MacroReflection.instance_method(:initialize).
      arity == 4
  end

  def options
    super

    @options[:sphinx_internal_filtered] = true
    @options
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb