Class: Ldapter::Schema::AbstractDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/ldapter/schema.rb

Direct Known Subclasses

DITStructureRule, LdapSyntax, NameDescObsoleteDefiniton

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (AbstractDefinition) initialize(string)

A new instance of AbstractDefinition



51
52
53
54
55
56
57
58
# File 'lib/ldapter/schema.rb', line 51

def initialize(string)
  @string = string.dup
  string = @string.dup
  @oid = extract_oid(string)
  array = build_array(string.dup)
  hash = array_to_hash(array)
  @attributes = hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(key, *args, &block) (private)



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ldapter/schema.rb', line 129

def method_missing(key,*args,&block)
  if key.to_s =~ /^x_.*[^!=]$/
    if args.size == 0
      if key.to_s[-1] == ??
        !!attributes[key.to_s[0..-2].to_sym]
      else
        attributes[key]
      end
    else
      raise ArgumentError, "wrong number of arguments (#{args.size} for 0)", caller
    end
  else
    super(key,*args,&block)
  end
end

Instance Attribute Details

- (Object) attributes (readonly)

Returns the value of attribute attributes



41
42
43
# File 'lib/ldapter/schema.rb', line 41

def attributes
  @attributes
end

- (Object) oid

Returns the value of attribute oid



40
41
42
# File 'lib/ldapter/schema.rb', line 40

def oid
  @oid
end

Class Method Details

+ (Object) attr_ldap_boolean(*attrs)



11
12
13
14
15
16
17
18
19
# File 'lib/ldapter/schema.rb', line 11

def attr_ldap_boolean(*attrs)
  attrs.each do |attr|
    class_eval(<<-EOS)
      def #{attr}?
        !!attributes[:#{attr}]
      end
    EOS
  end
end

+ (Object) attr_ldap_reader(*attrs) Also known as: attr_ldap_qdstring, attr_ldap_qdescr, attr_ldap_qdescrs, attr_ldap_oid, attr_ldap_oids, attr_ldap_noidlen, attr_ldap_numericoid



21
22
23
24
25
26
27
28
29
# File 'lib/ldapter/schema.rb', line 21

def attr_ldap_reader(*attrs)
  attrs.each do |attr|
    class_eval(<<-EOS)
      def #{attr}
        attributes[:#{attr}]
      end
    EOS
  end
end

Instance Method Details

- (Object) inspect



43
44
45
# File 'lib/ldapter/schema.rb', line 43

def inspect
  "#<#{self.class.inspect} #{@oid} #{attributes.inspect}>"
end

- (Object) to_s



47
48
49
# File 'lib/ldapter/schema.rb', line 47

def to_s
  @string
end