Class: DataMapper::Adapters::XmlAdapterCache

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-xml-adapter.rb

Instance Method Summary collapse

Constructor Details

#initializeXmlAdapterCache

Returns a new instance of XmlAdapterCache.



17
18
19
20
# File 'lib/dm-xml-adapter.rb', line 17

def initialize
  @mtimes = Hash.new()
  @classes = Hash.new()
end

Instance Method Details

#delete(classname, id) ⇒ Object



45
46
47
48
49
50
# File 'lib/dm-xml-adapter.rb', line 45

def delete(classname, id)
  hash = @classes[classname]
  unless hash == nil
    hash.delete(id.to_s)
  end
end

#delete_mtime(file) ⇒ Object



26
27
28
# File 'lib/dm-xml-adapter.rb', line 26

def delete_mtime(file)
    @mtimes.delete(file)
end

#get(classname, id) ⇒ Object



52
53
54
55
56
# File 'lib/dm-xml-adapter.rb', line 52

def get(classname, id)
    hash = @classes[classname]
    object = hash[id]
    return object
end

#get_mtime(file) ⇒ Object



30
31
32
# File 'lib/dm-xml-adapter.rb', line 30

def get_mtime(file)
  return @mtimes[file]
end

#put(classname, id, object) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/dm-xml-adapter.rb', line 34

def put(classname, id, object)
  
  # check to see if we have a classname entry
  if (@classes[classname] == nil)
    @classes[classname] = Hash.new
  end
      
  hash = @classes[classname]
  hash[id.to_s] = object
end

#set_mtime(file, mtime) ⇒ Object



22
23
24
# File 'lib/dm-xml-adapter.rb', line 22

def set_mtime(file, mtime)
   @mtimes[file] = mtime
end