Hi,
I'm having trouble to factor some simple code. Since, I have been stuck for several days now I ask the question here.
# Beginning of code
module DefWithName
def integer(name, options = {})
store_result name, MyInteger.new(options)
end
def id(name)
integer(name, an_options: true)
end
end
module DefWithoutName
def integer(options = {})
store_result MyInteger.new(options)
end
def id
integer(an_options: true)
end
end
class A; include DefWithName; end
class AA; include DefWithName; end
class B; include DefWithoutName; end
class BB; include DefWithoutName; end
# End of code
Constraints:
- The "id" function has to call "integer" and not "store_result" because it may be defined as a plugin.
- The functions must still raise ArgumentError as they already do.