T
Tim Clark
Hi everyone,
The quick version:
Is there a Ruby-ian way to get the alias method to propagate through
subclasses?
The longer one:
I've got two classes with some simple inheritance:
class Ticket
def unreserve
...
end
alias unhold unreserve
end
class FamilyTicket < Ticket
def unreserve
...
end
end
FamilyTicket adds a bit of functionality to Ticket, and are reserved
in different ways, so it's unreserve method overwrites its parent
class. I would still like to use the aliased method name - e.g.
ft = FamilyTicket.new
ft.unhold
However, the alias refers to Ticket#unreserve, not
FamilyTicket#unreserve. From the docs I understand that this is by
design, so my question is, is there a more Ruby-like way of doing the
following?
class Ticket
def unreserve
...
end
def unhold
unreserve
end
end
Cheers,
Tim Clark
The quick version:
Is there a Ruby-ian way to get the alias method to propagate through
subclasses?
The longer one:
I've got two classes with some simple inheritance:
class Ticket
def unreserve
...
end
alias unhold unreserve
end
class FamilyTicket < Ticket
def unreserve
...
end
end
FamilyTicket adds a bit of functionality to Ticket, and are reserved
in different ways, so it's unreserve method overwrites its parent
class. I would still like to use the aliased method name - e.g.
ft = FamilyTicket.new
ft.unhold
However, the alias refers to Ticket#unreserve, not
FamilyTicket#unreserve. From the docs I understand that this is by
design, so my question is, is there a more Ruby-like way of doing the
following?
class Ticket
def unreserve
...
end
def unhold
unreserve
end
end
Cheers,
Tim Clark