Sha256: be49f217a95fc1b199ec0854833a3fe14444b958aa64ce990a1fbf480ff47722

Contents?: true

Size: 671 Bytes

Versions: 11

Compression:

Stored size: 671 Bytes

Contents

module BetterRecord
  module Reflection
    class AbstractReflection
      def join_scope(table, foreign_klass)
        predicate_builder = predicate_builder(table)
        scope_chain_items = join_scopes(table, predicate_builder)
        klass_scope       = klass_join_scope(table, predicate_builder)

        if type
          klass_scope.where!(type => foreign_klass.__send__(options[:primary_type] || :table_name))
        end

        scope_chain_items.inject(klass_scope, &:merge!)
      end
    end

    class RuntimeReflection < AbstractReflection # :nodoc:
      delegate :scope, :type, :constraints, :get_join_keys, :options, to: :@reflection
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
better_record-0.6.1 lib/better_record/reflection.rb
better_record-0.6.0 lib/better_record/reflection.rb
better_record-0.5.5 lib/better_record/reflection.rb
better_record-0.5.4 lib/better_record/reflection.rb
better_record-0.5.1 lib/better_record/reflection.rb
better_record-0.5.0 lib/better_record/reflection.rb
better_record-0.4.0 lib/better_record/reflection.rb
better_record-0.3.0 lib/better_record/reflection.rb
better_record-0.2.0 lib/better_record/reflection.rb
better_record-0.1.1 lib/better_record/reflection.rb
better_record-0.1.0 lib/better_record/reflection.rb