Class: Seymour::Feed
- Inherits:
-
Object
- Object
- Seymour::Feed
- Defined in:
- lib/seymour/feed.rb
Constant Summary collapse
- @@feed_classes =
[]
Instance Attribute Summary collapse
-
#owner ⇒ Object
Returns the value of attribute owner.
Class Method Summary collapse
Instance Method Summary collapse
- #activity_ids ⇒ Object
- #bulk_push(activities) ⇒ Object
-
#initialize(owner) ⇒ Feed
constructor
A new instance of Feed.
- #push(activity) ⇒ Object
- #remove(activity) ⇒ Object
- #remove_id(activity_id) ⇒ Object
- #sort(options = {}) ⇒ Object
- #sort!(options = {}) ⇒ Object
- #sorted_push(activities) ⇒ Object (also: #insert_and_order)
Constructor Details
#initialize(owner) ⇒ Feed
Returns a new instance of Feed.
22 23 24 |
# File 'lib/seymour/feed.rb', line 22 def initialize(owner) @owner = owner end |
Instance Attribute Details
#owner ⇒ Object
Returns the value of attribute owner.
4 5 6 |
# File 'lib/seymour/feed.rb', line 4 def owner @owner end |
Class Method Details
.distribute(activity) ⇒ Object
9 10 11 |
# File 'lib/seymour/feed.rb', line 9 def distribute(activity) activity.distribute end |
.feed_classes ⇒ Object
17 18 19 |
# File 'lib/seymour/feed.rb', line 17 def feed_classes @@feed_classes end |
.inherited(subclass) ⇒ Object
13 14 15 |
# File 'lib/seymour/feed.rb', line 13 def inherited(subclass) @@feed_classes << subclass end |
Instance Method Details
#activity_ids ⇒ Object
26 27 28 |
# File 'lib/seymour/feed.rb', line 26 def activity_ids redis.lrange(key, 0, max_size).map{|id| id.to_i } end |
#bulk_push(activities) ⇒ Object
34 35 36 37 38 |
# File 'lib/seymour/feed.rb', line 34 def bulk_push(activities) activities.each do |activity| push(activity) end end |
#push(activity) ⇒ Object
30 31 32 |
# File 'lib/seymour/feed.rb', line 30 def push(activity) perform_push(activity.id) if should_push?(activity) end |
#remove(activity) ⇒ Object
40 41 42 |
# File 'lib/seymour/feed.rb', line 40 def remove(activity) remove_id activity.id end |
#remove_id(activity_id) ⇒ Object
44 45 46 |
# File 'lib/seymour/feed.rb', line 44 def remove_id(activity_id) redis.lrem(key, 0, activity_id) end |
#sort(options = {}) ⇒ Object
52 53 54 |
# File 'lib/seymour/feed.rb', line 52 def sort( = {}) redis.sort(key, ) end |
#sort!(options = {}) ⇒ Object
48 49 50 |
# File 'lib/seymour/feed.rb', line 48 def sort!( = {}) sort({ :order => "DESC", :store => key }.merge()) # replaces itself with sorted list end |
#sorted_push(activities) ⇒ Object Also known as: insert_and_order
56 57 58 59 |
# File 'lib/seymour/feed.rb', line 56 def sorted_push(activities) bulk_push(activities) sort! end |