Sha256: 84b44570b5d54ef6d08c1a50233f8051cd06fdebb472ce8dacf2c9134cdddc6a

Contents?: true

Size: 900 Bytes

Versions: 71

Compression:

Stored size: 900 Bytes

Contents

module ActiveFedora
  class UnsavedDigitalObject
    def assign_pid
      @pid ||= Sufia::IdService.mint
    end
  end

  class Base
    def stream
      Nest.new(self.class.name, $redis)[to_param]
    rescue
      nil
    end

    def self.stream
      Nest.new(name, $redis)
    rescue
      nil
    end

    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

    def create_event(action, timestamp)
      event_id = $redis.incr("events:latest_id")
      $redis.hmset("events:#{event_id}", "action", action, "timestamp", timestamp)
      event_id
    rescue
      nil
    end

    def log_event(event_id)
      stream[:event].lpush(event_id)
    rescue
      nil
    end
  end
end



Version data entries

71 entries across 71 versions & 2 rubygems

Version Path
sufia-4.0.0.rc1 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-4.0.0.rc1 lib/sufia/models/active_fedora/redis.rb
sufia-4.0.0.beta4 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-4.0.0.beta4 lib/sufia/models/active_fedora/redis.rb
sufia-models-4.0.0.beta3 lib/sufia/models/active_fedora/redis.rb
sufia-4.0.0.beta3 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-4.0.0.beta2 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-4.0.0.beta2 lib/sufia/models/active_fedora/redis.rb
sufia-4.0.0.beta1 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-4.0.0.beta1 lib/sufia/models/active_fedora/redis.rb
sufia-models-3.7.2 lib/sufia/models/active_fedora/redis.rb
sufia-3.7.2 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-3.7.1 lib/sufia/models/active_fedora/redis.rb
sufia-3.7.1 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-3.7.0 lib/sufia/models/active_fedora/redis.rb
sufia-3.7.0 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-3.6.1 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-3.6.1 lib/sufia/models/active_fedora/redis.rb
sufia-3.6.0 sufia-models/lib/sufia/models/active_fedora/redis.rb
sufia-models-3.6.0 lib/sufia/models/active_fedora/redis.rb