Class: DataMapper::Adapters::XmlAdapterCache
- Inherits:
-
Object
- Object
- DataMapper::Adapters::XmlAdapterCache
- Defined in:
- lib/dm-xml-adapter.rb
Instance Method Summary collapse
- #delete(classname, id) ⇒ Object
- #delete_mtime(file) ⇒ Object
- #get(classname, id) ⇒ Object
- #get_mtime(file) ⇒ Object
-
#initialize ⇒ XmlAdapterCache
constructor
A new instance of XmlAdapterCache.
- #put(classname, id, object) ⇒ Object
- #set_mtime(file, mtime) ⇒ Object
Constructor Details
#initialize ⇒ XmlAdapterCache
Returns a new instance of XmlAdapterCache.
18 19 20 21 |
# File 'lib/dm-xml-adapter.rb', line 18 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
27 28 29 |
# File 'lib/dm-xml-adapter.rb', line 27 def delete_mtime(file) @mtimes.delete(file) end |
#get(classname, id) ⇒ Object
52 53 54 55 |
# File 'lib/dm-xml-adapter.rb', line 52 def get(classname, id) hash = @classes[classname] return hash[id] end |
#get_mtime(file) ⇒ Object
31 32 33 |
# File 'lib/dm-xml-adapter.rb', line 31 def get_mtime(file) return @mtimes[file] end |
#put(classname, id, object) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/dm-xml-adapter.rb', line 35 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
23 24 25 |
# File 'lib/dm-xml-adapter.rb', line 23 def set_mtime(file, mtime) @mtimes[file] = mtime end |