Class: ActiverecordHoarder::Storage
- Inherits:
-
Object
- Object
- ActiverecordHoarder::Storage
- Defined in:
- lib/activerecord_hoarder/storage.rb
Class Method Summary collapse
- .check_configured ⇒ Object
- .configure(storage:, storage_options:) ⇒ Object
- .is_configured? ⇒ Boolean
- .new(table_name, storage_override: nil, storage_options_override: {}) ⇒ Object
Class Method Details
.check_configured ⇒ Object
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. = self.storage = storage self end |
.is_configured? ⇒ Boolean
24 25 26 |
# File 'lib/activerecord_hoarder/storage.rb', line 24 def self.is_configured? storage.present? && .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, .merge()) end |