Class: ClassRoom::Client::ProxyObject
- Inherits:
-
Object
- Object
- ClassRoom::Client::ProxyObject
- Defined in:
- lib/classroom.rb
Overview
ProxyObject acts as a local proxy for ClassRoom clients and handles passing through requests to run class methods and initializations
Class Method Summary collapse
- .class_name ⇒ Object
- .class_name=(d) ⇒ Object
-
.drb ⇒ Object
Set up a weird /true/ class variable system (that is, class variable == class variable, not weird hierarchy variable-foo as is Ruby’s wont).
- .drb=(d) ⇒ Object
-
.method_missing(method, *args) ⇒ Object
If we’re getting methods called on the proxy, they must be for the remote class rather than a method, so ask the ClassRoom server to run the class_method on the supplied object.
Instance Method Summary collapse
- #class_name ⇒ Object
- #drb ⇒ Object
-
#initialize(*args) ⇒ ProxyObject
constructor
Create an instance of the remote class.
-
#method_missing(method, *args) ⇒ Object
Return the ‘real’ class name def class; @class_name; end.
Constructor Details
#initialize(*args) ⇒ ProxyObject
Create an instance of the remote class
218 219 220 |
# File 'lib/classroom.rb', line 218 def initialize(*args) @drbed_object = drb.send(:new_instance_of, self.class.to_s.to_sym, *args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Return the ‘real’ class name def class; @class_name; end
232 233 234 |
# File 'lib/classroom.rb', line 232 def method_missing(method, *args) @drbed_object.send(method, *args) end |
Class Method Details
.class_name ⇒ Object
212 |
# File 'lib/classroom.rb', line 212 def self.class_name; @@class_name[self.to_s.to_sym]; end |
.class_name=(d) ⇒ Object
213 |
# File 'lib/classroom.rb', line 213 def self.class_name=(d); (@@class_name ||= {})[self.to_s.to_sym] = d; end |
.drb ⇒ Object
Set up a weird /true/ class variable system (that is, class variable == class variable, not weird hierarchy variable-foo as is Ruby’s wont)
210 |
# File 'lib/classroom.rb', line 210 def self.drb; @@drb[self.to_s.to_sym]; end |
.drb=(d) ⇒ Object
211 |
# File 'lib/classroom.rb', line 211 def self.drb=(d); (@@drb ||= {})[self.to_s.to_sym] = d; end |
.method_missing(method, *args) ⇒ Object
If we’re getting methods called on the proxy, they must be for the remote class rather than a method, so ask the ClassRoom server to run the class_method on the supplied object
225 226 227 |
# File 'lib/classroom.rb', line 225 def self.method_missing(method, *args) drb.send(:class_method, class_name, method, *args) end |
Instance Method Details
#class_name ⇒ Object
215 |
# File 'lib/classroom.rb', line 215 def class_name; @@class_name[self.class.to_s.to_sym]; end |
#drb ⇒ Object
214 |
# File 'lib/classroom.rb', line 214 def drb; @@drb[self.class.to_s.to_sym]; end |