Module: KirguduBase::Models::FixableElements::InstanceMethods

Included in:
DynamicPages::Element
Defined in:
app/helpers/kirgudu_base/models/fixable_elements.rb

Instance Method Summary collapse

Instance Method Details

#fix_parent_entry(parent_entry, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/kirgudu_base/models/fixable_elements.rb', line 27

def fix_parent_entry(parent_entry, options = {})
  options ||= {}
  self.get_kb_fixable_attributes.each do |fix_attribute|
    fix_value = self.send(fix_attribute)

    if fix_attribute.is_a?(Array)
      fix_value.each do |fix_value_array_entry|
        if fix_value_array_entry.respond_to?(:fix_parent_entry)
          fix_value_array_entry.fix_parent_entry(parent_entry)
        end
      end
    elsif fix_value.is_a?(Hash)
      fix_value.each_pair do |key, fix_value_hash_entry|
        if fix_value_hash_entry.respond_to?(:fix_parent_entry)
          fix_value_hash_entry.fix_parent_entry(parent_entry)
        end
      end
    elsif fix_value.respond_to?(:fix_parent_entry)
      fix_value.fix_parent_entry(parent_entry)
    end if fix_value
  end
end