Class: Database::Backends

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/database/backends.rb

Instance Method Summary collapse

Constructor Details

#initialize(pathname) ⇒ Backends

Returns a new instance of Backends.



12
13
14
15
16
# File 'lib/database/backends.rb', line 12

def initialize(pathname)
  @pathname = pathname
  @loose    = Loose.new(pathname)
  @stores   = [@loose] + packed
end

Instance Method Details

#has?(oid) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/database/backends.rb', line 22

def has?(oid)
  @stores.any? { |store| store.has?(oid) }
end

#load_info(oid) ⇒ Object



26
27
28
# File 'lib/database/backends.rb', line 26

def load_info(oid)
  @stores.reduce(nil) { |info, store| info || store.load_info(oid) }
end

#load_raw(oid) ⇒ Object



30
31
32
# File 'lib/database/backends.rb', line 30

def load_raw(oid)
  @stores.reduce(nil) { |raw, store| raw || store.load_raw(oid) }
end

#pack_pathObject



18
19
20
# File 'lib/database/backends.rb', line 18

def pack_path
  @pathname.join("pack")
end

#prefix_match(name) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/database/backends.rb', line 34

def prefix_match(name)
  oids = @stores.reduce([]) do |list, store|
    list + store.prefix_match(name)
  end

  oids.uniq
end