Sha256: 3b23d19aa179d293b840ca99d26af53ef6a4a37810597d31510ef960d377536c

Contents?: true

Size: 744 Bytes

Versions: 17

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

# This scoped approach is only available in Rails 4.0. This behaviour is
# superseded by AssociationReflection for Rails 4.1, and was preceded by
# ConditionsReflection for Rails 3.2.
class ThinkingSphinx::ActiveRecord::Depolymorph::ScopedReflection <
  ThinkingSphinx::ActiveRecord::Depolymorph::BaseReflection

  def call
    klass.new reflection.macro, name, scope, options,
      reflection.active_record
  end

  private

  def scope
    lambda { |association|
      reflection = association.reflection
      klass      = reflection.class_name.constantize
      where(
        association.parent.aliased_table_name.to_sym =>
        {reflection.foreign_type => klass.base_class.name}
      )
    }
  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/scoped_reflection.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb