lib/arid_cache/cache_proxy/result_processor.rb
def to_result
        if @options.count_only?
          get_count

        elsif @options.proxy?(:out)
          results =
            if @cached.nil? || !@options.raw?
              @result
            else
              @cached
            end
          filtered = filter_results(results)
          # If proxying out, we always have to proxy the result.
          # If proxying both ways, we don't need to proxy the result after seeding the cache.
          if !@options.raw? && (@options[:proxy_out] || @cached.nil?)
            proxy_result = run_user_proxy(:out, filtered)
            if filtered.is_a?(WillPaginate::Collection) && proxy_result.is_a?(Enumerable)
              filtered.replace(proxy_result)
            else
              proxy_result
            end
          else
            filtered
          end

        # If proxying in, we want to return what was stored in the cache, not what was
        # returned by the block.  So with :proxy_in, using :raw => true has no effect.
        elsif @options.proxy?(:in)
          filter_results(@cached || @result)

        elsif (@cached || @result).is_a?(AridCache::CacheProxy::CachedResult) && (@cached || @result).klass == NilClass && !(@cached || @result).has_ids?
          nil

        elsif @options.raw?
          result =
            if @cached.is_a?(AridCache::CacheProxy::CachedResult)
              @cached
            else
              @result
            end
          if @options.deprecated_raw?
            result
          elsif result.is_a?(AridCache::CacheProxy::CachedResult)
            filter_results(result.ids)
          else
            filter_results(result)
          end

        elsif is_cached_result?
          fetch_activerecords(filter_results(@result.ids, false)) # order in db or after
        elsif order_in_database?
          fetch_activerecords(filter_results(@result, false)) # order in db or after
        else
          filter_results(@result)
        end
      end
# Apply any options like pagination or ordering and return the result, which
# is either some base type, or usually, a list of active records.
Apply any options like pagination or ordering and return the result, which
is either some base type, or usually, a list of active records.
Apply any options like pagination or ordering and return the result which is either some base type or usually a list of active records .
def to_result
        if @options.count_only?
          get_count
        elsif @options.proxy?(:out)
          results =
            if @cached.nil? || !@options.raw?
              @result
            else
              @cached
            end
          filtered = filter_results(results)
          if !@options.raw? && (@options[:proxy_out] || @cached.nil?)
            proxy_result = run_user_proxy(:out, filtered)
            if filtered.is_a?(WillPaginate::Collection) && proxy_result.is_a?(Enumerable)
              filtered.replace(proxy_result)
            else
              proxy_result
            end
          else
            filtered
          end
        elsif @options.proxy?(:in)
          filter_results(@cached || @result)
        elsif (@cached || @result).is_a?(AridCache::CacheProxy::CachedResult) && (@cached || @result).klass == NilClass && !(@cached || @result).has_ids?
          nil
        elsif @options.raw?
          result =
            if @cached.is_a?(AridCache::CacheProxy::CachedResult)
              @cached
            else
              @result
            end
          if @options.deprecated_raw?
            result
          elsif result.is_a?(AridCache::CacheProxy::CachedResult)
            filter_results(result.ids)
          else
            filter_results(result)
          end
        elsif is_cached_result?
          fetch_activerecords(filter_results(@result.ids, false)) 
        elsif order_in_database?
          fetch_activerecords(filter_results(@result, false)) 
        else
          filter_results(@result)
        end
      end
def to_result if @options . count_only? get_count elsif @options . proxy? ( :out ) results = if @cached . nil? || ! @options . raw? @result else @cached end filtered = filter_results ( results ) if ! @options . raw? && ( @options [ :proxy_out ] || @cached . nil? ) proxy_result = run_user_proxy ( :out , filtered ) if filtered . is_a? ( WillPaginate :: Collection ) && proxy_result . is_a? ( Enumerable ) filtered . replace ( proxy_result ) else proxy_result end else filtered end elsif @options . proxy? ( :in ) filter_results ( @cached || @result ) elsif ( @cached || @result ) . is_a? ( AridCache :: CacheProxy :: CachedResult ) && ( @cached || @result ) . klass == NilClass && ! ( @cached || @result ) . has_ids? nil elsif @options . raw? result = if @cached . is_a? ( AridCache :: CacheProxy :: CachedResult ) @cached else @result end if @options . deprecated_raw? result elsif result . is_a? ( AridCache :: CacheProxy :: CachedResult ) filter_results ( result . ids ) else filter_results ( result ) end elsif is_cached_result? fetch_activerecords ( filter_results ( @result . ids , false ) ) elsif order_in_database? fetch_activerecords ( filter_results ( @result , false ) ) else filter_results ( @result ) end end
Apply any options like pagination or ordering and return the result, which
is either some base type, or usually, a list of active records.
Apply any options like pagination or ordering and return the result which is either some base type or usually a list of active records .
# If proxying out, we always have to proxy the result. # If proxying both ways, we don't need to proxy the result after seeding the cache. # If proxying in, we want to return what was stored in the cache, not what was # returned by the block.  So with :proxy_in, using :raw => true has no effect. # order in db or after # order in db or after