D
Douglas Livingstone
Why does this work:
class ComplexObject
attr_accessor :colour
def initialize # :yield: c
ComplexObject.module_eval "undef_method :colour="
end
end
But this doesn't?
class ComplexObject
attr_accessor :colour
def initialize # :yield: c
self.module_eval "undef_method :colour="
end
end
(btw, I know about attr_reader, I'm just looking for ways around the
"disadvantages" for "Initializing complex objects" at
http://www.rubygarden.org/ruby?RubyIdioms )
I assumed that self == ComplexObject, but obviously not... why is that?
Cheers,
Douglas
class ComplexObject
attr_accessor :colour
def initialize # :yield: c
ComplexObject.module_eval "undef_method :colour="
end
end
But this doesn't?
class ComplexObject
attr_accessor :colour
def initialize # :yield: c
self.module_eval "undef_method :colour="
end
end
(btw, I know about attr_reader, I'm just looking for ways around the
"disadvantages" for "Initializing complex objects" at
http://www.rubygarden.org/ruby?RubyIdioms )
I assumed that self == ComplexObject, but obviously not... why is that?
Cheers,
Douglas