Sha256: f4217ba54fa541110d0590436e160cb118b067c7fca4b5b127b4c3c148b654f0

Contents?: true

Size: 556 Bytes

Versions: 3

Compression:

Stored size: 556 Bytes

Contents

module Restruct
  class Structure

    attr_reader :redis, :id

    def initialize(options={})
      @redis = options[:redis] || Restruct.redis
      @id = Id.new options[:id] || Restruct.generate_id
    end

    def ==(object)
      object.class == self.class && 
      object.id == id && 
      object.redis == redis
    end
    alias_method :eql?, :==

    def dump
      redis.call 'DUMP', id
    end

    def restore(dump)
      destroy
      redis.call 'RESTORE', id, 0, dump
    end

    def destroy
      redis.call 'DEL', id
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
restruct-0.0.3 lib/restruct/structure.rb
restruct-0.0.2 lib/restruct/structure.rb
restruct-0.0.1 lib/restruct/structure.rb