Sha256: e6214505dcd138f00eb372ab2ddafe05d0b0df6ac192100e3dba480266fb62c6

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

require 'fileutils'

module Nitro

# Adds support for caching.

module Caching

  # Action caching.

  module Actions 

    def self.append_features(base) # :nodoc: 
      super
      base.extend(ClassMethods)
    end

    module ClassMethods

      def cache_action(*actions)
        return unless caching_enabled?
        
        before_filter(
          %{
            fragment_name = "\#\{@action_name\}\#{@request.query_string}"
            if fragment = Fragment.get(fragment_name)
              @out = fragment
              return
            end
          },
          :only => actions
        )
        
        after_filter(
          %{ 
            fragment_name = "\#\{@action_name\}\#{@request.query_string}"
            Fragment.put(fragment_name, @out) 
          },
          :only => actions
        )
      end
      
    end

    private 

    #--
    # FIXME: not implemented.
    #++
    
    def expire_action(*actions)
      return unless caching_enabled?

      for action in [actions].flatten
        expire_fragment(action)
      end
    end

  end

end

end

# * George Moschovitis  <gm@navel.gr>

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nitro-0.21.0 lib/nitro/caching/actions.rb
nitro-0.21.2 lib/nitro/caching/actions.rb
nitro-0.23.0 lib/nitro/caching/actions.rb
nitro-0.25.0 lib/nitro/caching/actions.rb
nitro-0.26.0 lib/nitro/caching/actions.rb
nitro-0.24.0 lib/nitro/caching/actions.rb
nitro-0.22.0 lib/nitro/caching/actions.rb
nitro-0.27.0 lib/nitro/caching/actions.rb