The method respond_to? tests to see whether an instance of Address has access to :given_name, inherited from the Name class.
#!/usr/bin/env ruby
class Name
attr_accessor :given_name, :family_name
end
class Address < Name
attr_accessor :street, :city, :state, :country
end
a = Address.new
puts a.respond_to?(:given_name) # => true
Related examples in the same category