Class: Ldaptic::Schema::AbstractDefinition

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ AbstractDefinition

Returns a new instance of AbstractDefinition.



51
52
53
54
55
56
57
58
# File 'lib/ldaptic/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

#method_missing(key, *args, &block) ⇒ Object (private)



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ldaptic/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

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#oidObject

Returns the value of attribute oid.



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

def oid
  @oid
end

Class Method Details

.attr_ldap_boolean(*attrs) ⇒ Object



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

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

.attr_ldap_reader(*attrs) ⇒ Object 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/ldaptic/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

#inspectObject



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

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

#to_sObject



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

def to_s
  @string
end