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.
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 |