class Eternity::Index
Attributes
name[R]
Public Class Methods
all()
click to toggle source
# File lib/eternity/index.rb, line 31 def self.all sections_count = Eternity.keyspace[:index].sections.count names = Eternity.connection.call('KEYS', Eternity.keyspace[:index]['*']).map do |key| Restruct::Id.new(key).sections[sections_count] end.uniq names.map { |name| new name } end
new(name=nil)
click to toggle source
Calls superclass method
# File lib/eternity/index.rb, line 6 def initialize(name=nil) @name = name ? name.to_s : SecureRandom.uuid super connection: Eternity.connection, id: Eternity.keyspace[:index][@name] end
read_blob(sha1)
click to toggle source
# File lib/eternity/index.rb, line 25 def self.read_blob(sha1) Index.new.tap do |index| index.restore Blob.read :index, sha1 end end
Public Instance Methods
apply(delta)
click to toggle source
# File lib/eternity/index.rb, line 12 def apply(delta) delta.each do |collection, elements| elements.each do |id, change| args = [id, change['data']].compact self[collection].send change['action'], *args end end end
write_blob()
click to toggle source
# File lib/eternity/index.rb, line 21 def write_blob Blob.write :index, dump end