Module: ODE::ObjectID
Overview
TODO dR*, dQ*, dMass* (maybe just need constructors for these)
Constant Summary
collapse
- @@by_id =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methodname, *args, &block) ⇒ Object
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
# File 'lib/ode.rb', line 236
def method_missing(methodname, *args, &block)
camelized = ODE.camelize_method_name(methodname)
meth = nil
klass = self.class
while (meth == nil and klass != nil)
class_name = klass.to_s.sub(/.*::/,'')
ode_function = "d#{class_name}#{camelized}".intern
ode_getter = "d#{class_name}Get#{camelized}".intern
if (ODE.respond_to?(ode_function))
meth = ODE.method(ode_function)
elsif (ODE.respond_to?(ode_getter))
meth = ODE.method(ode_getter)
end
klass = klass.superclass
end
if (meth)
args = args[0] if (methodname.to_s =~ /=$/ and args.length == 1 and args[0].kind_of?(Array))
args = ODE.convert_args(args)
ODE.convert_return_value(meth.call(@id, *args, &block))
else
super(methodname, *args, &block)
end
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
220
221
222
|
# File 'lib/ode.rb', line 220
def id
@id
end
|
Class Method Details
.by_id(id) ⇒ Object
227
228
229
|
# File 'lib/ode.rb', line 227
def self.by_id(id)
@@by_id[id]
end
|
.set_by_id(id, v) ⇒ Object
231
232
233
234
|
# File 'lib/ode.rb', line 231
def self.set_by_id(id, v)
@@by_id[id] = v
end
|
Instance Method Details
#initialize(*args) ⇒ Object
222
223
224
225
|
# File 'lib/ode.rb', line 222
def initialize(*args)
@id = ODE.method("d#{self.class.to_s.sub(/.*::/,'')}Create").call(*(ODE.convert_args(args)))
@@by_id[@id] = self
end
|