Class: ODDB::Remote::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb/remote/object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#remoteObject (readonly)

Returns the value of attribute remote.



7
8
9
# File 'lib/oddb/remote/object.rb', line 7

def remote
  @remote
end

#sourceObject (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

#uidObject

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