S
Sam Roberts
I want to allow method calls during initialization, but not after:
class Foo
attr_writer pt
def initialize
yield self
# doesn't work
remove_method 'opt='
# doesn't work
class < self
remove_method 'opt='
end
# there must be a way?????
end
end
f = Foo.new { |s| s.opt = 4 }
# I want this to fail!
f.opt = 1
This has to be possible... whats the magic? Should I use
#method_missing, so I can decide to respond to it only during
initialization?
Thanks,
Sam
class Foo
attr_writer pt
def initialize
yield self
# doesn't work
remove_method 'opt='
# doesn't work
class < self
remove_method 'opt='
end
# there must be a way?????
end
end
f = Foo.new { |s| s.opt = 4 }
# I want this to fail!
f.opt = 1
This has to be possible... whats the magic? Should I use
#method_missing, so I can decide to respond to it only during
initialization?
Thanks,
Sam