Class: Xampl::SimplePersister

Inherits:
Persister show all
Defined in:
lib/xamplr/persisters/simple.rb

Instance Attribute Summary

Attributes inherited from Persister

#automatic, #block_changes, #cache_hits, #expunged, #format, #last_write_count, #name, #read_count, #rolled_back, #slow_sync, #syncing, #total_cache_hits, #total_read_count, #total_rollback_count, #total_sync_count, #total_write_count, #write_count

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Persister

#busy, #close, #count_changed, #do_sync_write, #done_sync_write, #expunge, #find_known, #find_xampl, #has_not_changed, #introduce, #is_busy, #lazy_load, #lookup, #optimise, #print_stats, #put_changed, #query_implemented, #realise, replace, #represent, #rollback, #rollback_cleanup, #shutdown, #start_sync_write, #sync

Constructor Details

#initialize(name = nil, format = nil, ignore = nil) ⇒ SimplePersister

Returns a new instance of SimplePersister.



5
6
7
8
9
10
# File 'lib/xamplr/persisters/simple.rb', line 5

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

  @module_map = {}
  @cache = {}
end

Class Method Details

.kindObject



12
13
14
# File 'lib/xamplr/persisters/simple.rb', line 12

def SimplePersister.kind
  :simple
end

Instance Method Details

#cache(xampl) ⇒ Object



27
28
29
# File 'lib/xamplr/persisters/simple.rb', line 27

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

#clear_cacheObject



34
35
36
# File 'lib/xamplr/persisters/simple.rb', line 34

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

#has_changed(xampl) ⇒ Object



23
24
25
# File 'lib/xamplr/persisters/simple.rb', line 23

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

#kindObject



16
17
18
# File 'lib/xamplr/persisters/simple.rb', line 16

def kind
  SimplePersister.kind
end

#read(klass, pid, target = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/xamplr/persisters/simple.rb', line 42

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

#sync_doneObject



20
21
# File 'lib/xamplr/persisters/simple.rb', line 20

def sync_done
end

#uncache(xampl) ⇒ Object



31
32
# File 'lib/xamplr/persisters/simple.rb', line 31

def uncache(xampl)
end

#write(xampl) ⇒ Object



38
39
40
# File 'lib/xamplr/persisters/simple.rb', line 38

def write(xampl)
  return true
end