Project

General

Profile

« Previous | Next » 

Revision f25d0aed

Added by Marc Dequènes about 15 years ago

  • ID f25d0aed079fd07a63406f33f9080966e6a84151

[fix/evol] ensure a shadow/object/aspect is not cast(/post-cast) multiple times, and btw correct the raise_error() method

View differences:

lib/ldap_shadows/elements.rb
module ClassMethods
# initializers
def cast; end
def cast_relations; end
def cast
if @cast_done
raise_error _("element '%s' already initialized") % self.handle
end
@cast_done = true
end
def cast_relations
if @cast_rel_done
raise_error _("element '%s' already post-initialized") % self.handle
end
@cast_rel_done = true
end
# default empty hooks
def hook_before_create(item); end
......
protected
def self.raise_error(msg)
def raise_error(msg)
raise ProcessingError, msg
end
end
lib/ldap_shadows/elements/aspect.rb
include LdapElement
def self.cast_relations
super
deps = self.parameters[:mapping][:depend_aspects] || []
deps.each do |aspect_name|
aspect = self.shadow.get_aspect(aspect_name)
lib/ldap_shadows/elements/object.rb
ldap_mapping :prefix => '', :classes => ['top'], :scope => :sub
def self.cast
super
ldap_mapping self.parameters[:mapping]
end
def self.cast_relations
super
object_rel = {}
object_rel.merge!(self.parameters[:relations]) if self.parameters.include?(:relations)
if self.parameters[:presentation].has_key?(:allowed_aspects)
lib/ldap_shadows/shadow.rb
end
def cast
if @cast
raise PreProcessingError, _("SHadow '%s' already initialized") % @name
end
@container_elements.each_value do |e_models|
e_models.each_value do |e_klass|
e_klass.cast
......
e_klass.cast_relations
end
end
@cast = true
end
def objects

Also available in: Unified diff