lib/arid_cache/cache_proxy/result_processor.rb
def to_cache
        # Check if it's an association first, because it doesn't trigger the select if it's
        # a named scope.  Calling respond_to? on an association proxy will trigger a select
        # because it loads up the target and passes the respond_to? on to it.
        @cached =
          if @options.proxy?(:in)
            if is_activerecord_reflection?
              @result = @result.collect { |r| r } # force it to load
            end
            run_user_proxy(:in, @result)
          elsif is_activerecord_reflection? # Don't trigger it unless we really have to
            if @options.count_only?
              lazy_cache.count = @result.count
            else
              lazy_cache.ids = @result.collect { |r| r[:id] }
              lazy_cache.klass = Utilities.collection_klass(@result) || result_klass
              lazy_cache.count = @result.size
            end
            lazy_cache
          elsif is_activerecord?
            lazy_cache.ids = @result.collect { |r| r[:id] }
            lazy_cache.count = @result.size
            lazy_cache.klass = @result.first.class
            lazy_cache
          elsif is_empty? && !AridCache.raw_with_options # deprecated behaviour
            lazy_cache.ids = @result
            lazy_cache.count = 0
            lazy_cache.klass = result_klass
            lazy_cache
          elsif @result.nil? # so we can distinguish a cached nil vs an empty cache
            lazy_cache.klass = NilClass
            lazy_cache
          else
            @result
          end
      end
# Return the result to cache.  For base types the original result is
# returned.  ActiveRecords return a CachedResult.
Return the result to cache.  For base types the original result is
returned.
Return the result to cache . For base types the original result is returned .
def to_cache
        @cached =
          if @options.proxy?(:in)
            if is_activerecord_reflection?
              @result = @result.collect { |r| r } 
            end
            run_user_proxy(:in, @result)
          elsif is_activerecord_reflection? 
            if @options.count_only?
              lazy_cache.count = @result.count
            else
              lazy_cache.ids = @result.collect { |r| r[:id] }
              lazy_cache.klass = Utilities.collection_klass(@result) || result_klass
              lazy_cache.count = @result.size
            end
            lazy_cache
          elsif is_activerecord?
            lazy_cache.ids = @result.collect { |r| r[:id] }
            lazy_cache.count = @result.size
            lazy_cache.klass = @result.first.class
            lazy_cache
          elsif is_empty? && !AridCache.raw_with_options 
            lazy_cache.ids = @result
            lazy_cache.count = 0
            lazy_cache.klass = result_klass
            lazy_cache
          elsif @result.nil? 
            lazy_cache.klass = NilClass
            lazy_cache
          else
            @result
          end
      end
def to_cache @cached = if @options . proxy? ( :in ) if is_activerecord_reflection? @result = @result . collect { | r | r } end run_user_proxy ( :in , @result ) elsif is_activerecord_reflection? if @options . count_only? lazy_cache . count = @result . count else lazy_cache . ids = @result . collect { | r | r [ :id ] } lazy_cache . klass = Utilities . collection_klass ( @result ) || result_klass lazy_cache . count = @result . size end lazy_cache elsif is_activerecord? lazy_cache . ids = @result . collect { | r | r [ :id ] } lazy_cache . count = @result . size lazy_cache . klass = @result . first . class lazy_cache elsif is_empty? && ! AridCache . raw_with_options lazy_cache . ids = @result lazy_cache . count = 0 lazy_cache . klass = result_klass lazy_cache elsif @result . nil? lazy_cache . klass = NilClass lazy_cache else @result end end
Return the result to cache.
Return the result to cache .
# Check if it's an association first, because it doesn't trigger the select if it's # a named scope.  Calling respond_to? on an association proxy will trigger a select # because it loads up the target and passes the respond_to? on to it. # force it to load # Don't trigger it unless we really have to # deprecated behaviour # so we can distinguish a cached nil vs an empty cache