Sha256: 40313fcc0f87943ed68ada78a16209c953cf94970c1099a9ba3c5fc523278c4b

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

module CanTango
  class Ability
    module Cache
      class SessionCache < BaseCache
        attr_accessor :session

        # will be called with :session => session (pointing to user session)
        def initialize name, options = {}
          super # will set all instance vars using options hash
          @cache = cache
          @cache.configure_with :type => :memory
          raise "SessionCache must be initialized with a :session option" if !session
          session[:rules_cache] = @cache
        end

        def store
          session[:rules_cache]
        end

        def load key
          store.load! key
        end

        def save key, rules
          store.save! key, rules
        end

        def invalidate! key
          store.delete key
        end

        def cache
          CanTango::Cache::MonetaCache.instance
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.8.0 lib/cantango/ability/cache/session_cache.rb