Class: Seymour::Store::List
- Inherits:
-
Base
- Object
- Base
- Seymour::Store::List
show all
- Defined in:
- lib/seymour/store/list.rb
Instance Attribute Summary
Attributes inherited from Base
#key
Instance Method Summary
collapse
Methods inherited from Base
#activity_ids, #bulk_push, #initialize, #max_size, #redis, #remove
Instance Method Details
#ids ⇒ Object
5
6
7
|
# File 'lib/seymour/store/list.rb', line 5
def ids
redis.lrange(key, 0, max_size).map(&:to_i)
end
|
#push(activity) ⇒ Object
9
10
11
|
# File 'lib/seymour/store/list.rb', line 9
def push(activity)
perform_push(activity.id) if should_push?(activity)
end
|
#remove_all ⇒ Object
17
18
19
|
# File 'lib/seymour/store/list.rb', line 17
def remove_all
redis.del(key)
end
|
#remove_id(id) ⇒ Object
13
14
15
|
# File 'lib/seymour/store/list.rb', line 13
def remove_id(id)
redis.lrem(key, 0, id)
end
|
#sort(options = {}) ⇒ Object
25
26
27
|
# File 'lib/seymour/store/list.rb', line 25
def sort(options = {})
redis.sort(key, options)
end
|
#sort!(options = {}) ⇒ Object
21
22
23
|
# File 'lib/seymour/store/list.rb', line 21
def sort!(options = {})
sort({ :order => "DESC", :store => key }.merge(options)) end
|
#sorted_push(activities) ⇒ Object
Also known as:
insert_and_order
29
30
31
32
|
# File 'lib/seymour/store/list.rb', line 29
def sorted_push(activities)
bulk_push(activities)
sort!
end
|