Module: GOM::Storage

Defined in:
lib/gom/storage.rb

Defined Under Namespace

Classes: Adapter, AdapterNotFoundError, Configuration, Counter, Fetcher, ReadOnlyError, Remover, Saver

Class Method Summary collapse

Class Method Details

.collection(storage_name, *arguments) ⇒ Object



48
49
50
# File 'lib/gom/storage.rb', line 48

def self.collection(storage_name, *arguments)
  Configuration[storage_name].adapter.collection *arguments
end

.configure(&block) ⇒ Object



17
18
19
# File 'lib/gom/storage.rb', line 17

def self.configure(&block)
  Configuration.configure &block
end

.count(storage_name) ⇒ Object



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

def self.count(storage_name)
  Counter.new(storage_name).perform
end

.fetch(id_string) ⇒ Object



30
31
32
33
# File 'lib/gom/storage.rb', line 30

def self.fetch(id_string)
  id = id_string.is_a?(String) ? GOM::Object::Id.new(id_string) : nil
  Fetcher.new(id).object
end

.remove(object_or_id) ⇒ Object



39
40
41
42
# File 'lib/gom/storage.rb', line 39

def self.remove(object_or_id)
  object_or_id = GOM::Object::Id.new object_or_id if object_or_id.is_a?(String)
  Remover.new(object_or_id).perform
end

.setupObject



21
22
23
24
# File 'lib/gom/storage.rb', line 21

def self.setup
  GOM::Object::Mapping.clear!
  Configuration.setup_all
end

.store(object, storage_name = nil) ⇒ Object



35
36
37
# File 'lib/gom/storage.rb', line 35

def self.store(object, storage_name = nil)
  Saver.new(object, storage_name).perform
end

.teardownObject



26
27
28
# File 'lib/gom/storage.rb', line 26

def self.teardown
  Configuration.teardown_all
end