Class: ActiverecordHoarder::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_hoarder/storage.rb

Class Method Summary collapse

Class Method Details

.check_configuredObject



10
11
12
13
# File 'lib/activerecord_hoarder/storage.rb', line 10

def self.check_configured
  raise ::ActiverecordHoarder::StorageError.new("storage needs to be configured") unless is_configured?

end

.configure(storage:, storage_options:) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/activerecord_hoarder/storage.rb', line 15

def self.configure(storage:, storage_options:)
  ::ActiverecordHoarder::Storages.is_valid_storage?(storage)

  self.storage_options = storage_options
  self.storage = storage

  self
end

.is_configured?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/activerecord_hoarder/storage.rb', line 24

def self.is_configured?
  storage.present? && storage_options.is_a?(Hash)
end

.new(table_name, storage_override: nil, storage_options_override: {}) ⇒ Object



4
5
6
7
8
# File 'lib/activerecord_hoarder/storage.rb', line 4

def self.new(table_name, storage_override: nil, storage_options_override: {})
  self.check_configured
  storage_class = ::ActiverecordHoarder::Storages.retrieve(storage_override || storage)
  storage_class.new(table_name, storage_options.merge(storage_options_override))
end