T
Toby Rodwell
I'd like to check an object's "parent" to see if it has a certain
method, so for example, given ...
class House(type)
attr_accessor :rooms, :type_of_house
@rooms = []
...
def type_of_house
type
end
end
class Room
...
end
my_room = Room.new
my_house = House.new
my_house.rooms.push(my_room)
... then is it somehow possible to ask ...
my_room.<PARENT>.respond_to?(type_of_house) ?
(I know 'House' is not really the parent of 'Room', and so I suspect the
answer is "no", but it can't hurt to ask. Thanks.
method, so for example, given ...
class House(type)
attr_accessor :rooms, :type_of_house
@rooms = []
...
def type_of_house
type
end
end
class Room
...
end
my_room = Room.new
my_house = House.new
my_house.rooms.push(my_room)
... then is it somehow possible to ask ...
my_room.<PARENT>.respond_to?(type_of_house) ?
(I know 'House' is not really the parent of 'Room', and so I suspect the
answer is "no", but it can't hurt to ask. Thanks.