Module: OmniStore::Storage::Local

Extended by:
Local
Included in:
Local
Defined in:
lib/omnistore/storage/local.rb,
lib/omnistore/storage/local/mountpoint.rb

Defined Under Namespace

Classes: Mountpoint

Instance Method Summary collapse

Instance Method Details

#delete(path, mp = mountpoint) ⇒ Object



36
37
38
# File 'lib/omnistore/storage/local.rb', line 36

def delete(path, mp = mountpoint)
  mp.delete(path)
end

#each(&block) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/omnistore/storage/local.rb', line 48

def each(&block)
  if block_given?
    @@keys.each{|key| yield new_mountpoint(key) }
  else
    Enumerator.new(@@keys.map{|key| new_mountpoint(key) })
  end
end

#exist?(path, mp = mountpoint) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/omnistore/storage/local.rb', line 32

def exist?(path, mp = mountpoint)
  mp.exist?(path)
end

#mount!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/omnistore/storage/local.rb', line 8

def mount!
  @@keys = {}
  case mountpoint = OmniStore::Config.mountpoint
  when Array
    mountpoint.each do |m|
      validate(m)
      @@keys[m] = {:name => File.basename(m), :dir => m}
    end
  when Hash
    mountpoint.each do |k,v|
      validate(v)
      @@keys[k] = {:name => k, :dir => v}
    end
  else
    m = mountpoint.to_s
    validate(m)
    @@keys[m] = {:name => File.basename(m), :dir => m}
  end
end

#mountpoint(key = @@keys.keys.first) ⇒ Object



28
29
30
# File 'lib/omnistore/storage/local.rb', line 28

def mountpoint(key = @@keys.keys.first)
  new_mountpoint(key)
end

#read(path, options = {}, mp = mountpoint, &block) ⇒ Object



40
41
42
# File 'lib/omnistore/storage/local.rb', line 40

def read(path, options = {}, mp = mountpoint, &block)
  mp.read(path, options, &block)
end

#write(path, options_or_data = nil, options = {}, mp = mountpoint) ⇒ Object



44
45
46
# File 'lib/omnistore/storage/local.rb', line 44

def write(path, options_or_data = nil, options = {}, mp = mountpoint)
  mp.write(path, options_or_data, options)
end