I do not know exactly what behavior you are looking for or why you want to use metaprogramming , but considering that you have a Transaccional
module:
module Transaccional
# métodos
end
You could do it by adding the transaccional
method to the class Class
, which is responsible for making include
; for example:
class Class
def transaccional
self.class_eval("include Transaccional")
end
end
Now using transaccional
within the body of the class will be the same as using include Transaccional
.
If you only want to add the method dynamically and without metaprogramming then the only thing you should do is this:
Persona.include(Transaccional)
In this case you will not need to put anything in the body of the class Persona
:
class Persona
include Lockeable
attr_accesor :nombre, :edad
# ...
end