Class: Creeper::Extensions::Proxy
- Inherits:
- BasicObject
- Defined in:
- lib/creeper/extensions/generic_proxy.rb
Instance Method Summary collapse
-
#initialize(performable, target, at = nil) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(performable, target, at = nil) ⇒ Proxy
Returns a new instance of Proxy.
4 5 6 7 8 |
# File 'lib/creeper/extensions/generic_proxy.rb', line 4 def initialize(performable, target, at=nil) @performable = performable @target = target @at = at end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/creeper/extensions/generic_proxy.rb', line 10 def method_missing(name, *args) # Creeper has a limitation in that its message must be JSON. # JSON can't round trip real Ruby objects so we use YAML to # serialize the objects to a String. The YAML will be converted # to JSON and then deserialized on the other side back into a # Ruby object. obj = [@target, name, args] if @at @performable.perform_at(@at, ::YAML.dump(obj)) else @performable.perform_async(::YAML.dump(obj)) end end |