Project

General

Profile

« Previous | Next » 

Revision accc97fc

Added by Marc Dequènes over 14 years ago

  • ID accc97fc6c0f1be28509ccdb5681471c097b6b6e

[cleanup] simplifications thanks to default config

View differences:

lib/ldap_shadows/elements/object.rb
object_rel = {}
object_rel.merge!(self.parameters[:relations]) if self.parameters.include?(:relations)
if self.parameters[:presentation].has_key?(:allowed_aspects)
self.parameters[:presentation][:allowed_aspects].each do |aspect_name|
aspect = self.shadow.get_aspect(aspect_name)
if aspect.nil?
raise PreProcessingError, _("Aspect '%s' is missing for object '%s'") % [aspect_name, self.handle]
end
aspect_data = aspect.parameters
object_rel.merge!(aspect_data[:relations]) if aspect_data.has_key?(:relations) and aspect_data[:relations]
self.parameters[:presentation][:allowed_aspects].each do |aspect_name|
aspect = self.shadow.get_aspect(aspect_name)
if aspect.nil?
raise PreProcessingError, _("Aspect '%s' is missing for object '%s'") % [aspect_name, self.handle]
end
aspect_data = aspect.parameters
object_rel.merge!(aspect_data[:relations])
end
return if object_rel.empty?
......
def human_name
attr_list = ['displayName', 'cn']
attr_list.unshift(self.class.parameters[:presentation][:name_attribute]) if self.class.parameters[:presentation].has_key?(:name_attribute)
name_attribute = self.class.parameters[:presentation][:name_attribute]
attr_list.unshift(name_attribute) unless name_attribute.nil?
attr_list.each do |attr|
if attr == 'dn'
return self.dn
......
def human_description
attr_list = ['description']
attr_list.unshift(self.class.parameters[:presentation][:desc_attribute]) if self.class.parameters[:presentation].has_key?(:desc_attribute)
desc_attribute = self.class.parameters[:presentation][:desc_attribute]
attr_list.unshift(desc_attribute) unless desc_attribute.nil?
attr_list.each do |attr|
if self.attribute_present?(attr)
return self[attr].is_a?(Array) ? self[attr][0] : self[attr]
......
def aspects
present_aspects = []
(self.class.parameters[:presentation][:allowed_aspects] || []).each do |aspect|
self.class.parameters[:presentation][:allowed_aspects].each do |aspect|
aspect_data = self.class.shadow.get_aspect(aspect).parameters
aspect_mapping = aspect_data[:mapping]
present_aspects << aspect if self.classes & aspect_mapping[:classes] == aspect_mapping[:classes]
......
end
def organized_data
ignored_attrs = self.class.shadow.get_config[:presentation][:hidden_attributes] || []
ignored_attrs += self.class.parameters[:presentation][:hidden_attributes] || []
ignored_attrs = self.class.shadow.get_config[:presentation][:hidden_attributes]
ignored_attrs += self.class.parameters[:presentation][:hidden_attributes]
attr_list = self.nonempty_attributes - ignored_attrs
expert_attributes = (self.class.parameters[:presentation][:expert_attributes] || [])
expert_attributes = self.class.parameters[:presentation][:expert_attributes]
admin_attributes = attr_list.select do |attr|
ActiveLdap::Base.schema.attribute(attr).operational?
end
......
taken_attr_list = attr_list
else
taken_attr_list = admin_attributes
if self.class.parameters[:presentation].has_key?(:associated_attributes)
taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
end
taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
taken_attr_list += self.class.possible_attributes
end
taken_attr_list = taken_attr_list.uniq & attr_list
......
add_class(*aspect_data[:mapping][:classes])
# recursive dependency enforcement
depends = aspect_data[:mapping][:depend_aspects] || []
depends.each do |dep_aspect|
aspect_data[:mapping][:depend_aspects].each do |dep_aspect|
add_aspect(dep_aspect)
end
end

Also available in: Unified diff