Class: ODBA::DRbIdConv
- Defined in:
- lib/odba/drbwrapper.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ DRbIdConv
constructor
A new instance of DRbIdConv.
- #odba_update(key, odba_id, object_id) ⇒ Object
- #to_id(obj) ⇒ Object
- #to_obj(ref) ⇒ Object
Constructor Details
#initialize(*args) ⇒ DRbIdConv
Returns a new instance of DRbIdConv.
53 54 55 56 |
# File 'lib/odba/drbwrapper.rb', line 53 def initialize(*args) super @unsaved = {} end |
Instance Method Details
#odba_update(key, odba_id, object_id) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/odba/drbwrapper.rb', line 57 def odba_update(key, odba_id, object_id) case key when :store @unsaved.store(object_id, odba_id) when :clean, :delete @unsaved.delete(object_id) end end |
#to_id(obj) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/odba/drbwrapper.rb', line 75 def to_id(obj) if(obj.is_a?(ODBA::Persistable)) if(obj.odba_unsaved?) obj.odba_add_observer(self) super else obj.odba_id.to_s end else super end end |
#to_obj(ref) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/odba/drbwrapper.rb', line 65 def to_obj(ref) test = ref if(test.is_a?(String) || (test = @unsaved[ref])) DRbWrapper.new(ODBA.cache.fetch(test.to_i)) else super end rescue RuntimeError => e raise RangeError, e. end |