Class: ODDB::Remote::Object
- Inherits:
-
Object
- Object
- ODDB::Remote::Object
- Defined in:
- lib/oddb/remote/object.rb
Direct Known Subclasses
Business::Company, Drugs::ActiveAgent, Drugs::Atc, Drugs::GalenicForm, Drugs::Package, Drugs::Part, Drugs::Product, Drugs::Sequence, Drugs::Substance, Drugs::Unit, Text::Document, Util::M10lDocument
Instance Attribute Summary collapse
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source, remote) ⇒ Object
constructor
A new instance of Object.
-
#uid ⇒ Object
def method_missing(*args, &block) @cache ||= @remote.send(*args, &block) rescue “remote: #selfself.class##’)” end.
Constructor Details
#initialize(source, remote) ⇒ Object
Returns a new instance of Object.
8 9 10 11 12 |
# File 'lib/oddb/remote/object.rb', line 8 def initialize(source, remote) @source = source @remote = remote @cache = {} end |
Instance Attribute Details
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
7 8 9 |
# File 'lib/oddb/remote/object.rb', line 7 def remote @remote end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/oddb/remote/object.rb', line 7 def source @source end |
Class Method Details
.delegate(*args) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/oddb/remote/object.rb', line 24 def delegate(*args) args.each { |arg| define_method(arg) { var = "@#{arg}" instance_variable_get(var) \ || instance_variable_set(var, @remote.send(arg)) } } end |
Instance Method Details
#uid ⇒ Object
def method_missing(*args, &block)
@cache[args] ||= @remote.send(*args, &block)
rescue
"remote: #{self.class}##{args.join(', ')}"
end
20 21 22 |
# File 'lib/oddb/remote/object.rb', line 20 def uid sprintf("%s#%s", @source, @remote.__drbref) end |