Revisions
-
Brandon Tilley renamed this gist
Nov 20, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ module Homepage module V2 class Board include Redis::Objects value :name value :exists counter :views set :comment_ids set :like_user_ids attr_reader :id def initialize(id) @id = id end def self.find(id) if redis.exists("board:#{id}:exists") new(id) else populate(::Board.find(id)) end end def self.populate(ar_board) board = new(ar_board.id) board.name = ar_board.name Array(ar_board.likes).map {|l| board. like_user_ids << l.user_id } board.views.incr(ar_board.views) board.exists = true board end def self.redis Redis.new(db:10) end end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ board = Homepage::V2::Board.find(2) => #<Homepage::V2::Board:0x007ff4466b9968 @id=2> pry(main)> board.views.to_i => 518 pry(main)> board.name => #<Redis::Value "SXSW Band Picks 2012">