Project

General

Profile

« Previous | Next » 

Revision 5aa80ef6

Added by Marc Dequènes almost 15 years ago

  • ID 5aa80ef6dfda9e07cb9c8359a9f94bec17214ca3

[fix] move missing attribute check into the save() method to ensure it is done after hooks (which can modify attributes and change the result of the test)

View differences:

lib/ldap_shadows/object.rb
end
def save
check_hooks
before_save_jobs
super
end
def save!
check_hooks
before_save_jobs
super
end
protected
def before_save_jobs
check_hooks
check_missing_attributes
end
def check_hooks
self.aspects.each do |aspect|
aklass = self.class.mapper.get_aspect_klass(aspect)
......
end
end
def check_missing_attributes
missing_fields = self.missing_attributes
unless missing_fields.empty?
miss_str = []
missing_fields.each do |field|
str = Translator.translate_field_name(field)
str += " [#{field}]" if $program_options[:handles]
miss_str << str
end
raise PreProcessingError, _("Cannot save the item; the following fields are missing: %s") %
miss_str.join(", ")
end
end
def fetch_attributes_data(attr_list, expert_attributes)
attr_data = self.attributes.collect do |key, val|
if attr_list.include?(key)

Also available in: Unified diff