Class: GOM::Object::Proxy
- Inherits:
-
Object
- Object
- GOM::Object::Proxy
show all
- Defined in:
- lib/gom/object/proxy.rb
Overview
The proxy that fetches an object if it’s needed and simply passes method calls to it.
Instance Method Summary
collapse
Constructor Details
#initialize(object_or_id) ⇒ Proxy
Returns a new instance of Proxy.
5
6
7
8
9
|
# File 'lib/gom/object/proxy.rb', line 5
def initialize(object_or_id)
@object, @id = object_or_id.is_a?(GOM::Object::Id) ?
[ nil, object_or_id ] :
[ object_or_id, nil ]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
26
27
28
29
|
# File 'lib/gom/object/proxy.rb', line 26
def method_missing(method_name, *arguments, &block)
fetch_object unless @object
@object.send method_name, *arguments, &block
end
|
Instance Method Details
16
17
18
19
|
# File 'lib/gom/object/proxy.rb', line 16
def id
fetch_id unless @id
@id && @id.to_s
end
|
11
12
13
14
|
# File 'lib/gom/object/proxy.rb', line 11
def object
fetch_object unless @object
@object
end
|
#storage_name ⇒ Object
21
22
23
24
|
# File 'lib/gom/object/proxy.rb', line 21
def storage_name
fetch_id unless @id
@id && @id.storage_name
end
|