Sha256: 5a51b16107bece8d2e47efbb9222fa14d721ece7165c18d0461078c3b46e2fbe

Contents?: true

Size: 1.05 KB

Versions: 37

Compression:

Stored size: 1.05 KB

Contents

module Xampl

  class SimplePersister < Persister

    def initialize(name=nil, format=nil)
      super(name, format)

      @module_map = {}
      @cache = {}
    end

    def SimplePersister.kind
      :simple
    end

    def kind
      SimplePersister.kind
    end

    def sync_done
    end

    def has_changed(xampl)
      throw :mixed_persisters unless self == xampl.persister
    end

    def cache(xampl)
      return Xampl.store_in_map(@cache, xampl) { xampl }
    end

    def uncache(xampl)
    end

    def clear_cache
      throw :really_bad_idea, "clearing the cache in a simple persister looses information"
    end

    def write(xampl)
      return true
    end

    def read(klass, pid, target=nil)
      xampl = Xampl.lookup_in_map(@cache, klass, pid)

      if (nil != xampl) then
        if target and target != xampl then
          target.invalidate
          throw(:cache_conflict)
        end
        throw(:load_unsupported) if xampl.load_needed
      end

      return xampl
    end
  end

  Xampl.register_persister_kind(SimplePersister)
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
hutch-xamplr-1.3.9 lib/xamplr/persisters/simple.rb
xamplr-1.9.13 lib/xamplr/persisters/simple.rb
xamplr-1.9.12 lib/xamplr/persisters/simple.rb
xamplr-1.9.11 lib/xamplr/persisters/simple.rb
xamplr-1.9.10 lib/xamplr/persisters/simple.rb
xamplr-1.9.9 lib/xamplr/persisters/simple.rb
xamplr-1.9.8 lib/xamplr/persisters/simple.rb
xamplr-1.9.7 lib/xamplr/persisters/simple.rb
xamplr-1.9.6 lib/xamplr/persisters/simple.rb
xamplr-1.9.5 lib/xamplr/persisters/simple.rb
xamplr-1.9.4 lib/xamplr/persisters/simple.rb
xamplr-1.9.3 lib/xamplr/persisters/simple.rb
xamplr-1.9.2 lib/xamplr/persisters/simple.rb
xamplr-1.9.1 lib/xamplr/persisters/simple.rb
xamplr-1.9.0 lib/xamplr/persisters/simple.rb
xamplr-1.3.15 lib/xamplr/persisters/simple.rb
xamplr-1.2.0 lib/xamplr/persisters/simple.rb