Class: AD::Framework::Utilities::EntryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ad-framework/utilities/entry_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ldap_entry, options = {}) ⇒ EntryBuilder

Returns a new instance of EntryBuilder.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ad-framework/utilities/entry_builder.rb', line 13

def initialize(ldap_entry, options = {})
  self.ldap_entry = ldap_entry
  
  if self.ldap_entry
    self.fields = AD::Framework::Fields.new(self.ldap_entry || {})
    if options[:reload]
      self.entry = options[:reload]
      self.reload
    else
      self.build
    end
  end
end

Instance Attribute Details

#entryObject

Returns the value of attribute entry.



11
12
13
# File 'lib/ad-framework/utilities/entry_builder.rb', line 11

def entry
  @entry
end

#fieldsObject

Returns the value of attribute fields.



11
12
13
# File 'lib/ad-framework/utilities/entry_builder.rb', line 11

def fields
  @fields
end

#ldap_entryObject

Returns the value of attribute ldap_entry.



11
12
13
# File 'lib/ad-framework/utilities/entry_builder.rb', line 11

def ldap_entry
  @ldap_entry
end

Instance Method Details

#buildObject



35
36
37
38
39
# File 'lib/ad-framework/utilities/entry_builder.rb', line 35

def build
  structure = self.classes_structure
  self.entry = structure[:structural_class].new({ :fields => self.fields })
  self.link_auxiliary_classes(structure)
end

#reloadObject



27
28
29
30
31
32
33
# File 'lib/ad-framework/utilities/entry_builder.rb', line 27

def reload
  self.entry.fields = self.fields
  self.entry.schema.attributes.each do |name|
    self.entry.send("#{name}_attribute_type").reset
  end
  self.link_auxiliary_classes
end