class InterMine::PathQuery::SubClassConstraint

Attributes

sub_class[RW]

Public Instance Methods

to_elem() click to toggle source
     # File lib/intermine/query.rb
1079 def to_elem
1080     attributes = {
1081         "path" => @path,
1082         "type" => @sub_class
1083     }
1084     elem = REXML::Element.new("constraint")
1085     elem.add_attributes(attributes)
1086     return elem
1087 end
validate() click to toggle source
     # File lib/intermine/query.rb
1089 def validate 
1090     if @path.elements.last.is_a?(InterMine::Metadata::AttributeDescriptor)
1091         raise ArgumentError, "#{self.class.name}s must be on objects or references to objects"
1092     end
1093     if @sub_class.length > 1
1094         raise ArgumentError, "#{self.class.name} expects sub-classes to be named as bare class names"
1095     end
1096     model = @path.model
1097     cdA = model.get_cd(@path.end_type)
1098     cdB = model.get_cd(@sub_class.end_type)
1099     unless ((cdB == cdA) or cdB.subclass_of?(cdA))
1100         raise ArgumentError, "The subclass in a #{self.class.name} must be a subclass of its path, but #{cdB} is not a subclass of #{cdA}"
1101     end
1102 
1103 end