Class: CodeRunner::Run::RunClassPropertyFetcher
- Inherits:
-
Object
- Object
- CodeRunner::Run::RunClassPropertyFetcher
show all
- Defined in:
- lib/coderunner/run.rb
Instance Method Summary
collapse
Constructor Details
104
105
106
|
# File 'lib/coderunner/run.rb', line 104
def initialize(the_class)
@my_class = the_class
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, value = nil) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/coderunner/run.rb', line 107
def method_missing(method, value=nil)
if method.to_s =~ /=$/
raise 'rcps should not be set outside class methods'
@my_class.instance_variable_set("@"+method.to_s.sub(/=/, ''), value)
else
the_class = @my_class
loop do
return the_class.instance_variable_get("@"+method.to_s) if the_class.instance_variables.include?(("@"+method.to_s).to_sym)
the_class = the_class.superclass
return nil unless the_class
end
end
end
|
Instance Method Details
125
126
127
|
# File 'lib/coderunner/run.rb', line 125
def [](prop)
send(prop.to_sym)
end
|