Sha256: c10c734648b20cb58575cbdcef7decf35494ddf988676e19f83dc83fd3189c1d
Contents?: true
Size: 1.49 KB
Versions: 19
Compression:
Stored size: 1.49 KB
Contents
module KirguduBase module Models module FixableElements module ClassMethods def fixable_attributes(*args) @fixable_attributes = self.get_kb_fixable_attributes options = args.extract_options! || {} args.each do |argument| unless argument.is_a?(Symbol) raise "Class: #{self} <br/>Fixable Attributes must be of Symbol Class".html_safe end if @fixable_attributes.include?(argument) raise "Class: #{self} <br/>Attribute '#{argument}' already added to Fixable for this Class".html_safe end @fixable_attributes << argument end end def get_kb_fixable_attributes @fixable_attributes || [] end end module InstanceMethods 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 end end end end
Version data entries
19 entries across 19 versions & 1 rubygems