Class: Datacaster::Runtimes::ObjectContext
- Inherits:
-
Base
- Object
- Base
- Datacaster::Runtimes::ObjectContext
show all
- Defined in:
- lib/datacaster/runtimes/object_context.rb
Instance Attribute Summary
Attributes inherited from Base
#reserved_instance_variables
Instance Method Summary
collapse
Methods inherited from Base
#Failure, #Success, call, #inspect, not_found!, send_to_parent, #to_s
Constructor Details
#initialize(parent, object) ⇒ ObjectContext
Returns a new instance of ObjectContext.
6
7
8
9
10
11
|
# File 'lib/datacaster/runtimes/object_context.rb', line 6
def initialize(parent, object)
super(parent)
@object = object
@reserved_instance_variables += instance_variables
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/datacaster/runtimes/object_context.rb', line 13
def method_missing(m, *args, &block)
if @object.respond_to?(m)
@object.public_send(m, *args, &block)
else
super
end
end
|
Instance Method Details
#after_call!(sender) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/datacaster/runtimes/object_context.rb', line 25
def after_call!(sender)
(sender.instance_variables.to_set - sender.reserved_instance_variables).each do |k|
@object.instance_variable_set(k, sender.instance_variable_get(k))
sender.remove_instance_variable(k)
end
super
end
|
#before_call!(sender) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/datacaster/runtimes/object_context.rb', line 33
def before_call!(sender)
super
(@object.instance_variables.to_set - sender.reserved_instance_variables).each do |k|
sender.instance_variable_set(k, @object.instance_variable_get(k))
end
end
|
#respond_to_missing?(m, include_private = false) ⇒ Boolean
21
22
23
|
# File 'lib/datacaster/runtimes/object_context.rb', line 21
def respond_to_missing?(m, include_private = false)
@object.respond_to?(m, include_private) || super
end
|