attr_reader simply generates the appropriate instance methods. It:
class Foo
attr_reader :bar
end
identical to:
class Foo
def bar
@bar
end
end
therefore alias_method works as you expected so that:
class Foo
attr_reader :favourites
alias_method :favorites, :favourites
attr_writer :favourites
alias_method :favorites=, :favourites=
end
source
share