Class: InterMine::PathQuery::SubClassConstraint
- Inherits:
-
Object
- Object
- InterMine::PathQuery::SubClassConstraint
- Includes:
- PathFeature
- Defined in:
- lib/intermine/query.rb
Instance Attribute Summary collapse
-
#sub_class ⇒ Object
Returns the value of attribute sub_class.
Attributes included from PathFeature
Instance Method Summary collapse
Instance Attribute Details
#sub_class ⇒ Object
Returns the value of attribute sub_class.
1073 1074 1075 |
# File 'lib/intermine/query.rb', line 1073 def sub_class @sub_class end |
Instance Method Details
#to_elem ⇒ Object
1075 1076 1077 1078 1079 1080 1081 1082 1083 |
# File 'lib/intermine/query.rb', line 1075 def to_elem attributes = { "path" => @path, "type" => @sub_class } elem = REXML::Element.new("constraint") elem.add_attributes(attributes) return elem end |
#validate ⇒ Object
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/intermine/query.rb', line 1085 def validate if @path.elements.last.is_a?(InterMine::Metadata::AttributeDescriptor) raise ArgumentError, "#{self.class.name}s must be on objects or references to objects" end if @sub_class.length > 1 raise ArgumentError, "#{self.class.name} expects sub-classes to be named as bare class names" end model = @path.model cdA = model.get_cd(@path.end_type) cdB = model.get_cd(@sub_class.end_type) unless ((cdB == cdA) or cdB.subclass_of?(cdA)) raise ArgumentError, "The subclass in a #{self.class.name} must be a subclass of its path, but #{cdB} is not a subclass of #{cdA}" end end |