Mega Code Archive

 
Categories / Ruby / Reflection
 

The method respond_to tests to see whether an instance of Address has access to

#!/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