def most_specific_domain_attribute(klass, attributes=nil)
      attributes ||= domain_attributes
      candidates = attributes.properties
      best = candidates.inject(nil) do |better, prop|
        # If the attribute can return the klass then the return type is a candidate.
        # In that case, the klass replaces the best candidate if it is more specific than
        # the best candidate so far.
        klass <= prop.type ? (better && better.type <= prop.type ? better : prop) : better
      end
      if best then
        logger.debug { "Most specific #{qp} -> #{klass.qp} reference from among #{candidates.qp} is #{best.declarer.qp}.#{best}." }
        best.to_sym
      end
    end
def most_specific_domain_attribute(klass, attributes=nil)
      attributes ||= domain_attributes
      candidates = attributes.properties
      best = candidates.inject(nil) do |better, prop|
        # If the attribute can return the klass then the return type is a candidate.
        # In that case, the klass replaces the best candidate if it is more specific than
        # the best candidate so far.
        klass <= prop.type ? (better && better.type <= prop.type ? better : prop) : better
      end
      if best then
        logger.debug { "Most specific #{qp} -> #{klass.qp} reference from among #{candidates.qp} is #{best.declarer.qp}.#{best}." }
        best.to_sym
      end
    end
Returns the most specific attribute which references the given target type, or nil if none.
 If the given class can be returned by more than on of the attributes, then the attribute
 is chosen whose return type most closely matches the given class.

 @param [Class] klass the target type
 @param [AttributeEnumerator, nil] attributes the attributes to check (default all domain attributes)
 @return [Symbol, nil] the most specific reference attribute, or nil if none