Class: MM::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/mm/repository.rb

Constant Summary collapse

FILE_NAME =
'.mm_pstore'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.destroyObject



20
21
22
# File 'lib/mm/repository.rb', line 20

def self.destroy
  File.delete(FILE_NAME) if File.exist?(FILE_NAME)
end

Instance Method Details

#[](key) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/mm/repository.rb', line 24

def [](key)
  return nil unless File.exist?(FILE_NAME)
  
  repository = PStore.new(FILE_NAME)
  repository.transaction(true) do
    repository[key]
  end
end

#[]=(key, value) ⇒ Object



33
34
35
36
37
38
# File 'lib/mm/repository.rb', line 33

def []=(key, value)
  repository = PStore.new(FILE_NAME)
  repository.transaction do
    repository[key] = value
  end
end