Class: Seymour::Feed

Inherits:
Object
  • Object
show all
Defined in:
lib/seymour/feed.rb

Constant Summary collapse

@@feed_classes =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#ownerObject

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_classesObject



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_idsObject



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

#insert_and_order(activities) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/seymour/feed.rb', line 42

def insert_and_order(activities)
  ids = (activity_ids.map(&:to_i) + activities.map(&:id)).sort.uniq

  remove_all

  ids.each do |id|
    perform_push(id)
  end
end

#push(activity, cmd = :lpush) ⇒ Object



30
31
32
# File 'lib/seymour/feed.rb', line 30

def push(activity, cmd = :lpush)
  perform_push(activity.id, cmd) if should_push?(activity)
end

#remove(activity) ⇒ Object



34
35
36
# File 'lib/seymour/feed.rb', line 34

def remove(activity)
  remove_id activity.id
end

#remove_id(activity_id) ⇒ Object



38
39
40
# File 'lib/seymour/feed.rb', line 38

def remove_id(activity_id)
  redis.lrem(key, 0, activity_id)
end