I would have thought that a class method context would be able to call
protected methods on an instance of that class. That does not seem to be
the case:
class Foo
def self.create_with_magic
newfoo = new()
newfoo.init_magic
return newfoo
end
def initialize
# no magic here
end
protected
def init_magic
# something magical
end
end
foo = Foo.create_with_magic #this will raise an exception
Is this just an oversight? A bug? Is there a rationale for it that I’m
not
seeing? I’m not looking for a workaround; I’ve already found a better
way
of doing what brought this to my attention. I am just looking for an
explanation.
–Greg