Class: LDAP::Server::Schema::ObjectClass
- Inherits:
-
Object
- Object
- LDAP::Server::Schema::ObjectClass
- Defined in:
- lib/ldap/server/schema.rb
Overview
Class holding an instance of an ObjectClassDescription (RFC2252 4.4)
Constant Summary collapse
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#may ⇒ Object
readonly
Returns the value of attribute may.
-
#must ⇒ Object
readonly
Returns the value of attribute must.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#obsolete ⇒ Object
readonly
Returns the value of attribute obsolete.
-
#oid ⇒ Object
readonly
Returns the value of attribute oid.
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
-
#sup ⇒ Object
readonly
Returns the value of attribute sup.
Instance Method Summary collapse
- #changed ⇒ Object
-
#initialize(str) ⇒ ObjectClass
constructor
A new instance of ObjectClass.
- #joinoids(pfx, arr, sfx) ⇒ Object
- #name ⇒ Object
- #to_def ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ ObjectClass
Returns a new instance of ObjectClass.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/ldap/server/schema.rb', line 528 def initialize(str) m = LDAP::Server::Syntax::ObjectClassDescription.match(str) raise LDAP::ResultError::InvalidAttributeSyntax, "Bad ObjectClassDescription #{str.inspect}" unless m @oid = m[1] @names = (m[2]||"").scan(/'(.*?)'/).flatten @desc = m[3] @obsolete = ! m[4].nil? @sup = (m[5]||"").scan(SCAN_WOID).flatten @struct = m[6] ? m[6].downcase.intern : :structural @must = (m[7]||"").scan(SCAN_WOID).flatten @may = (m[8]||"").scan(SCAN_WOID).flatten @def = nil end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def desc @desc end |
#may ⇒ Object (readonly)
Returns the value of attribute may.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def may @may end |
#must ⇒ Object (readonly)
Returns the value of attribute must.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def must @must end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def names @names end |
#obsolete ⇒ Object (readonly)
Returns the value of attribute obsolete.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def obsolete @obsolete end |
#oid ⇒ Object (readonly)
Returns the value of attribute oid.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def oid @oid end |
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def struct @struct end |
#sup ⇒ Object (readonly)
Returns the value of attribute sup.
524 525 526 |
# File 'lib/ldap/server/schema.rb', line 524 def sup @sup end |
Instance Method Details
#changed ⇒ Object
551 552 553 |
# File 'lib/ldap/server/schema.rb', line 551 def changed @def = nil end |
#joinoids(pfx, arr, sfx) ⇒ Object
577 578 579 580 581 582 583 584 585 586 |
# File 'lib/ldap/server/schema.rb', line 577 def joinoids(pfx,arr,sfx) return "" unless arr and !arr.empty? return "#{pfx}#{arr}#{sfx}" unless arr.is_a?(Array) a = arr.collect { |elem| elem.to_s } if a.size == 1 return "#{pfx}#{a.first}#{sfx}" else return "#{pfx}( #{a.join(" $ ")} )#{sfx}" end end |
#name ⇒ Object
543 544 545 |
# File 'lib/ldap/server/schema.rb', line 543 def name @names.first end |
#to_def ⇒ Object
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/ldap/server/schema.rb', line 555 def to_def return @def if @def ans = "( #{@oid} " if @names.nil? or @names.empty? # nothing elsif @names.size == 1 ans << "NAME '#{@names.first}' " else ans << "NAME ( " @names.each { |n| ans << "'#{n}' " } ans << ") " end ans << "DESC '#{@desc}' " if @desc ans << "OBSOLETE " if @obsolete ans << joinoids("SUP ",@sup," ") ans << "#{@struct.to_s.upcase} " if @struct ans << joinoids("MUST ",@must," ") ans << joinoids("MAY ",@may," ") ans << ")" @def = ans end |
#to_s ⇒ Object
547 548 549 |
# File 'lib/ldap/server/schema.rb', line 547 def to_s (@names && @names.first) || @oid end |