Module: RedisFeed::Source::InstanceMethods
- Defined in:
- lib/redis_feed/source.rb
Instance Method Summary collapse
- #event ⇒ Object
-
#feed_key ⇒ Object
you might want a shorter key.
- #outboxes ⇒ Object
- #push_event_to_readers ⇒ Object
- #readers ⇒ Object
- #subscribe(reader) ⇒ Object
Instance Method Details
#event ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/redis_feed/source.rb', line 35 def event # o means object, # e means event e = {:o => self.class.to_s, :id => self.id, :e => 'created'} # u means user e[:u] = @current_user.id if @current_user e.to_json end |
#feed_key ⇒ Object
you might want a shorter key
13 14 15 |
# File 'lib/redis_feed/source.rb', line 13 def feed_key "#{self.class.to_s}/#{id}" end |
#outboxes ⇒ Object
17 18 19 |
# File 'lib/redis_feed/source.rb', line 17 def outboxes "#{feed_key}/o" end |
#push_event_to_readers ⇒ Object
29 30 31 32 33 |
# File 'lib/redis_feed/source.rb', line 29 def push_event_to_readers readers.each do |reader| DB.lpush reader, event end end |
#readers ⇒ Object
25 26 27 |
# File 'lib/redis_feed/source.rb', line 25 def readers DB.smembers outboxes end |
#subscribe(reader) ⇒ Object
21 22 23 |
# File 'lib/redis_feed/source.rb', line 21 def subscribe(reader) DB.sadd outboxes, reader end |