Class: Stars
- Inherits:
-
Object
- Object
- Stars
- Defined in:
- lib/pig-media-server/model/data.rb,
lib/pig-media-server/model/data_use_rdb.rb
Class Method Summary collapse
- .list(user) ⇒ Object
- .star(user, key) ⇒ Object
- .star?(user, key) ⇒ Boolean
- .unstar(user, key) ⇒ Object
Class Method Details
.list(user) ⇒ Object
52 53 54 55 56 |
# File 'lib/pig-media-server/model/data.rb', line 52 def self.list user Pig.find Groonga['Stars'].select{|x| x._key =~ user }.to_a.map{|x| x._key.split('/').last} end |
.star(user, key) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/pig-media-server/model/data.rb', line 65 def self.star user, key key =user+'/'+key if Groonga['Stars'].add key Groonga['Stars'].delete key else Groonga['Stars'].add key end end |
.star?(user, key) ⇒ Boolean
58 59 60 61 62 63 |
# File 'lib/pig-media-server/model/data.rb', line 58 def self.star? user, key key =user+'/'+key !!Groonga['Stars'][key] rescue false end |
.unstar(user, key) ⇒ Object
74 75 76 77 |
# File 'lib/pig-media-server/model/data.rb', line 74 def self.unstar user, key key =user+'/'+key Groonga['Stars'].delete key end |