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.
58 59 60 61 |
# File 'lib/odba/drbwrapper.rb', line 58 def initialize(*args) super @unsaved = {} end |
Instance Method Details
#odba_update(key, odba_id, object_id) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/odba/drbwrapper.rb', line 63 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
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/odba/drbwrapper.rb', line 83 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
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/odba/drbwrapper.rb', line 72 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 |