Class: Datacaster::Runtimes::Base
- Inherits:
-
Object
- Object
- Datacaster::Runtimes::Base
show all
- Defined in:
- lib/datacaster/runtimes/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent = nil) ⇒ Base
Returns a new instance of Base.
25
26
27
28
29
30
31
|
# File 'lib/datacaster/runtimes/base.rb', line 25
def initialize(parent = nil)
@parent = parent
@reserved_instance_variables = Set.new(instance_variables + [:@reserved_instance_variables])
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
33
34
35
|
# File 'lib/datacaster/runtimes/base.rb', line 33
def method_missing(m, *args, &block)
self.class.send_to_parent(self, m, *args, &block)
end
|
Instance Attribute Details
#reserved_instance_variables ⇒ Object
Returns the value of attribute reserved_instance_variables.
6
7
8
|
# File 'lib/datacaster/runtimes/base.rb', line 6
def reserved_instance_variables
@reserved_instance_variables
end
|
Class Method Details
.call(r, proc, *args) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/datacaster/runtimes/base.rb', line 8
def self.call(r, proc, *args)
r.before_call!(r)
result = r.instance_exec(*args, &proc)
r.after_call!(r)
result
end
|
.not_found!(m) ⇒ Object
21
22
23
|
# File 'lib/datacaster/runtimes/base.rb', line 21
def self.not_found!(m)
raise NoMethodError.new("Method #{m.inspect} is not available in current runtime context")
end
|
.send_to_parent(r, m, *args, &block) ⇒ Object
15
16
17
18
19
|
# File 'lib/datacaster/runtimes/base.rb', line 15
def self.send_to_parent(r, m, *args, &block)
parent = r.instance_variable_get(:@parent)
not_found!(m) if parent.nil?
call(parent, -> { public_send(m, *args, &block) })
end
|
Instance Method Details
#after_call!(sender) ⇒ Object
41
42
43
|
# File 'lib/datacaster/runtimes/base.rb', line 41
def after_call!(sender)
@parent.after_call!(sender) if @parent
end
|
#before_call!(sender) ⇒ Object
45
46
47
|
# File 'lib/datacaster/runtimes/base.rb', line 45
def before_call!(sender)
@parent.before_call!(sender) if @parent
end
|
#Failure(v) ⇒ Object
61
62
63
|
# File 'lib/datacaster/runtimes/base.rb', line 61
def Failure(v)
Datacaster.ErrorResult(v)
end
|
#inspect ⇒ Object
49
50
51
|
# File 'lib/datacaster/runtimes/base.rb', line 49
def inspect
"#<#{self.class.name} parent: #{@parent.inspect}>"
end
|
#respond_to_missing?(m, include_private = false) ⇒ Boolean
37
38
39
|
# File 'lib/datacaster/runtimes/base.rb', line 37
def respond_to_missing?(m, include_private = false)
!@parent.nil? && @parent.respond_to?(m, include_private)
end
|
#Success(v) ⇒ Object
57
58
59
|
# File 'lib/datacaster/runtimes/base.rb', line 57
def Success(v)
Datacaster.ValidResult(v)
end
|
#to_s ⇒ Object
53
54
55
|
# File 'lib/datacaster/runtimes/base.rb', line 53
def to_s
inspect
end
|