Module: Recommendable::Ratable::Likable
- Defined in:
- lib/recommendable/ratable/likable.rb
Instance Method Summary collapse
-
#liked_by ⇒ Array
Fetch a list of users that have liked this item.
-
#liked_by_count ⇒ Fixnum
Get the number of users that have liked this item.
-
#liked_by_ids ⇒ Array
Get the IDs of users that have liked this item.
Instance Method Details
#liked_by ⇒ Array
Fetch a list of users that have liked this item.
7 8 9 |
# File 'lib/recommendable/ratable/likable.rb', line 7 def liked_by Recommendable.query(Recommendable.config.user_class, liked_by_ids) end |
#liked_by_count ⇒ Fixnum
Get the number of users that have liked this item
14 15 16 |
# File 'lib/recommendable/ratable/likable.rb', line 14 def liked_by_count Recommendable.redis.scard(Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(self.class, id)) end |
#liked_by_ids ⇒ Array
Get the IDs of users that have liked this item.
21 22 23 |
# File 'lib/recommendable/ratable/likable.rb', line 21 def liked_by_ids Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(self.class, id)) end |