Class: ODBA::DRbWrapper
- Inherits:
-
Object
show all
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/odba/drbwrapper.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of DRbWrapper.
15
16
17
|
# File 'lib/odba/drbwrapper.rb', line 15
def initialize(obj)
@obj = obj
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/odba/drbwrapper.rb', line 21
def method_missing(sym, *args)
if(block_given?)
res = @obj.__send__(sym, *args) { |*block_args|
yield *block_args.collect { |arg| __wrap(arg) }
}
__wrap(res)
else
res = @obj.__send__(sym, *args)
if(res.is_a?(Array))
res.collect { |item| __wrap(item) }
elsif(res.is_a?(Hash))
res.inject({}) { |memo, (key, value)|
memo.store(__wrap(key), __wrap(value))
memo
}
else
__wrap(res)
end
end
end
|
Instance Method Details
#__wrap(obj) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/odba/drbwrapper.rb', line 41
def __wrap(obj)
if(obj.is_a?(ODBA::Persistable))
DRbWrapper.new(obj.odba_instance)
else
obj
end
end
|
#__wrappee ⇒ Object
48
49
50
|
# File 'lib/odba/drbwrapper.rb', line 48
def __wrappee
@obj
end
|
#respond_to?(sym, *args) ⇒ Boolean
18
19
20
|
# File 'lib/odba/drbwrapper.rb', line 18
def respond_to?(sym, *args)
super || @obj.respond_to?(sym, *args)
end
|