module TDiary::IO::Comment
Public Instance Methods
restore_comment(diaries)
click to toggle source
# File lib/tdiary/io/rdb.rb, line 22 def restore_comment(diaries) diaries.each do |date, diary_object| db[:comments].filter(:diary_id => date).order_by(:no).select(:name, :mail, :last_modified, :visible, :comment).each do |row| comment = TDiary::Comment.new(row[:name], row[:mail], row[:comment], Time.at(row[:last_modified].to_i)) comment.show = row[:visible] diary_object.add_comment(comment) end end end
store_comment(diaries)
click to toggle source
# File lib/tdiary/io/rdb.rb, line 32 def store_comment(diaries) diaries.each do |diary_id, diary| no = 0 diary.each_comment(diary.count_comments(true)) do |com| no += 1 date = { diary_id: diary_id, no: no } body = { name: com.name, mail: com.mail, last_modified: com.date.to_i, visible: com.visible?, comment: com.body } comment = db[:comments].filter(date) if comment.count > 0 comment.update(body) else db[:comments].insert(date.merge(body)) end end end end