Class: ActiveFedora::Base
- Inherits:
-
Object
- Object
- ActiveFedora::Base
- Defined in:
- lib/sufia/active_fedora/redis.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #create_event(action, timestamp) ⇒ Object
- #events(size = -1)) ⇒ Object
- #log_event(event_id) ⇒ Object
- #stream ⇒ Object
Class Method Details
.stream ⇒ Object
15 16 17 18 19 |
# File 'lib/sufia/active_fedora/redis.rb', line 15 def self.stream Nest.new(name, $redis) rescue nil end |
Instance Method Details
#create_event(action, timestamp) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sufia/active_fedora/redis.rb', line 32 def create_event(action, ) event_id = $redis.incr("events:latest_id") $redis.hmset("events:#{event_id}", "action", action, "timestamp", ) event_id rescue nil end |
#events(size = -1)) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sufia/active_fedora/redis.rb', line 21 def events(size=-1) stream[:event].lrange(0, size).map do |event_id| { action: $redis.hget("events:#{event_id}", "action"), timestamp: $redis.hget("events:#{event_id}", "timestamp") } end rescue [] end |
#log_event(event_id) ⇒ Object
40 41 42 43 44 |
# File 'lib/sufia/active_fedora/redis.rb', line 40 def log_event(event_id) stream[:event].lpush(event_id) rescue nil end |
#stream ⇒ Object
9 10 11 12 13 |
# File 'lib/sufia/active_fedora/redis.rb', line 9 def stream Nest.new(self.class.name, $redis)[to_param] rescue nil end |