module MongoTools
Public Instance Methods
calc_md5(md_string)
click to toggle source
# File lib/md5.rb, line 36 def calc_md5(md_string) ret=Digest::MD5.hexdigest(md_string) ret end
concat_string(field_names,start_with)
click to toggle source
# File lib/md5.rb, line 10 def concat_string(field_names,start_with) retString = start_with field_names.each do |field| field_content = read_attribute(field).inspect retString = retString + field_content end retString end
find_or_create_with_md5(elements)
click to toggle source
aufter that method the element exists in al cases.
it returns true if the item has to be created otherwise false
# File lib/md5.rb, line 23 def find_or_create_with_md5(elements) md5_string = md5_create(elements) if !self.class.where(md5: md5_string).exists? self.md5 = md5_string self.save! return true else return false end end
md5_create(field_names)
click to toggle source
# File lib/md5.rb, line 5 def md5_create(field_names) calc_md5(concat_string(field_names,"")) end