MatchingRuleUse

class
Superclass
Object
Included Modules
Treequel::Constants::Patterns
Extended With
Loggability
Treequel::AttributeDeclarations

This is a class for representing matchingRuleUse declarations in a Treequel::Schema.

Attributes

attr_oids[R]

The OIDs of the attributes the matchingRuleUse applies to

desc[RW]

The matchingRuleUse's description

extensions[RW]

The matchingRuleUse's extensions (as a String)

names[R]

The Array of the matchingRuleUse's names

oid[R]

The matchingRuleUse's oid

schema[R]

The schema the matchingRuleUse belongs to

Public Class Methods

anchor
new( schema, oid, attr_oids, names=nil, desc=nil, obsolete=false, extensions=nil )

Create a new MatchingRuleUse

# File lib/treequel/schema/matchingruleuse.rb, line 50
def initialize( schema, oid, attr_oids, names=nil, desc=nil, obsolete=false, extensions=nil )
        @schema     = schema

        @oid        = oid
        @names      = names
        @desc       = desc
        @obsolete   = obsolete ? true : false
        @attr_oids  = attr_oids

        @extensions = extensions

        super()
end
anchor
parse( schema, description )

Parse an MatchingRuleUse entry from a matchingRuleUse description from a schema.

# File lib/treequel/schema/matchingruleuse.rb, line 28
def self::parse( schema, description )
        unless match = ( LDAP_MATCHING_RULE_USE_DESCRIPTION.match(description) )
                raise Treequel::ParseError, "failed to parse matchingRuleUse from %p" % [ description ]
        end

        oid, names, desc, obsolete, attr_oids, extensions = match.captures
        # Treequel.logger.debug "  parsed matchingRuleUse: %p" % [ match.captures ]

        # Normalize the attributes
        names     = Treequel::Schema.parse_names( names )
        desc      = Treequel::Schema.unquote_desc( desc )
        attr_oids = Treequel::Schema.parse_oids( attr_oids )

        return self.new( schema, oid, attr_oids, names, desc, obsolete, extensions )
end

Public Instance Methods

anchor
attribute_types()

Return Treequel::Schema::AttributeType objects for each of the types this MatchingRuleUse applies to.

# File lib/treequel/schema/matchingruleuse.rb, line 136
def attribute_types
        return self.attr_oids.collect {|oid| self.schema.attribute_types[oid] }
end
anchor
inspect()

Return a human-readable representation of the object suitable for debugging

# File lib/treequel/schema/matchingruleuse.rb, line 122
def inspect
        return "#<%s:0x%0x %s(%s) %p -> %p >" % [
                self.class.name,
                self.object_id / 2,
                self.name,
                self.oid,
                self.desc,
                self.attr_oids,
        ]
end
anchor
name()

Return the first of the matchingRuleUse's names, if it has any, or nil.

# File lib/treequel/schema/matchingruleuse.rb, line 92
def name
        return self.names.first
end
anchor
to_s()

Returns the matchingRuleUse as a String, which is the RFC4512-style schema description.

# File lib/treequel/schema/matchingruleuse.rb, line 107
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 << "APPLIES %s" % [ Treequel::Schema.oids(self.attr_oids) ]
        parts << self.extensions.strip             unless self.extensions.empty?

        return "( %s )" % [ parts.join(' ') ]
end