This is a class for representing matchingRule declarations in a Treequel::Schema.
The matchingRule's description
The matchingRule's extensions (as a String)
The Array of the matchingRule's names
The matchingRule's oid
The schema the matchingRule belongs to
The oid of the matchingRule's SYNTAX
Create a new MatchingRule
# File lib/treequel/schema/matchingrule.rb, line 48
def initialize( schema, oid, syntax_oid, names=nil, desc=nil, obsolete=false, extensions=nil )
@schema = schema
@oid = oid
@syntax_oid = syntax_oid
@names = names
@desc = desc
@obsolete = obsolete ? true : false
@extensions = extensions
super()
end
Parse an MatchingRule entry from a matchingRule description from a schema.
# File lib/treequel/schema/matchingrule.rb, line 27
def self::parse( schema, description )
unless match = ( LDAP_MATCHING_RULE_DESCRIPTION.match(description) )
raise Treequel::ParseError, "failed to parse matchingRule from %p" % [ description ]
end
oid, names, desc, obsolete, syntax_oid, extensions = match.captures
# Treequel.logger.debug " parsed matchingRule: %p" % [ match.captures ]
# Normalize the attributes
names = Treequel::Schema.parse_names( names )
desc = Treequel::Schema.unquote_desc( desc )
return self.new( schema, oid, syntax_oid, names, desc, obsolete, extensions )
end
Return a human-readable representation of the object suitable for debugging
# File lib/treequel/schema/matchingrule.rb, line 120
def inspect
return "#<%s:0x%0x %s(%s) %s %sSYNTAX: %p>" % [
self.class.name,
self.object_id / 2,
self.name,
self.oid,
self.desc,
self.obsolete? ? "(OBSOLETE)" : '',
self.syntax,
]
end
Return the first of the matchingRule's names, if it has any, or
nil
.
# File lib/treequel/schema/matchingrule.rb, line 90
def name
return self.names.first
end
Return the Treequel::Schema::LDAPSyntax object that corresponds to the matchingRule's SYNTAX attribute.
# File lib/treequel/schema/matchingrule.rb, line 135
def syntax
return self.schema.ldap_syntaxes[ self.syntax_oid ]
end
Returns the matchingRule as a String, which is the RFC4512-style schema description.
# File lib/treequel/schema/matchingrule.rb, line 105
def to_s
parts = [ self.oid ]
parts << "NAME %s" % Treequel::Schema.qdescrs( self.names ) unless self.names.empty?
parts << "DESC '%s'" % [ self.desc ] if self.desc
parts << "OBSOLETE" if self.obsolete?
parts << "SYNTAX %s" % [ self.syntax_oid ]
parts << self.extensions.strip unless self.extensions.empty?
return "( %s )" % [ parts.join(' ') ]
end