Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. class Message
  2. class << self; attr_accessor :cache; end
  3. attr_accessor :id
  4. attr_accessor :body
  5.  
  6. def self.find(id)
  7. new(id,@cache.transaction{|c| c[id] })
  8. end
  9.  
  10. def initialize(id, body)
  11. self.id = id
  12. self.body = body.squeeze(' ').strip
  13. self.class.cache = PStore.new('message_cache.pstore')
  14. end
  15.  
  16. def save
  17. self.class.cache.transaction{|c| c[@id] = @body }
  18. end
  19.  
  20. def to_html
  21. @body.gsub(/\n/,"<br/>")
  22. end
  23. end
Add Comment
Please, Sign In to add comment