J
-j B-
I have seen examples of catching unkown methods called on a class with
method_missing.
For example:
class Example
def initialize(...)
#...
end
def method_missing(item)
call = item.id2name
process(call)
end
end
But I'm not sure if that is an 'acceptable' way to do things. Also,
suppose that I wanted to add a method dynamically that takes arguments,
is this even possible?
My general thought is allowing functionality to be added to a program
dynamically based on a set of rules in a config file.
Any suggestions are welcome.
Thank you.
method_missing.
For example:
class Example
def initialize(...)
#...
end
def method_missing(item)
call = item.id2name
process(call)
end
end
But I'm not sure if that is an 'acceptable' way to do things. Also,
suppose that I wanted to add a method dynamically that takes arguments,
is this even possible?
My general thought is allowing functionality to be added to a program
dynamically based on a set of rules in a config file.
Any suggestions are welcome.
Thank you.