Module: SuperSettings::Storage::ClassMethods
- Defined in:
- lib/super_settings/storage.rb
Instance Attribute Summary collapse
-
#load_asynchronous ⇒ Object
writeonly
Set to true to force loading setting asynchronously in a background thread.
Instance Method Summary collapse
-
#active ⇒ Array<SuperSetting::Setting::Storage>
Return all non-deleted settings.
-
#all ⇒ Array<SuperSetting::Setting::Storage>
Storage classes must implent this method to return all settings included deleted ones.
-
#create_history(key:, changed_by:, created_at:, value: nil, deleted: false) ⇒ void
Create a history item for the setting.
-
#destroy_all ⇒ Object
Implementing classes can override this method to delete all settings.
-
#find_by_key(key) ⇒ SuperSetting::Setting::Storage
Storage classes must implement this method to return a settings by it’s key.
-
#last_updated_at ⇒ Time
Storage classes must implement this method to return most recent time that any setting was updated.
-
#load_asynchronous? ⇒ Boolean
Return true if it’s safe to load setting asynchronously in a background thread.
-
#transaction(&block) ⇒ void
Implementing classes can override this method to wrap an operation in an atomic transaction.
-
#updated_since(timestamp) ⇒ Array<SuperSetting::Setting::Storage>
Storage classes must implement this method to return all settings updates since the specified timestamp.
-
#with_connection(&block) ⇒ void
Implementing classes can override this method to setup a thread safe connection within a block.
Instance Attribute Details
#load_asynchronous=(value) ⇒ Object (writeonly)
Set to true to force loading setting asynchronously in a background thread.
102 103 104 |
# File 'lib/super_settings/storage.rb', line 102 def load_asynchronous=(value) @load_asynchronous = value end |
Instance Method Details
#active ⇒ Array<SuperSetting::Setting::Storage>
Return all non-deleted settings.
38 39 40 |
# File 'lib/super_settings/storage.rb', line 38 def active all.reject(&:deleted?) end |
#all ⇒ Array<SuperSetting::Setting::Storage>
Storage classes must implent this method to return all settings included deleted ones.
29 30 31 32 33 |
# File 'lib/super_settings/storage.rb', line 29 def all # :nocov: raise NotImplementedError # :nocov: end |
#create_history(key:, changed_by:, created_at:, value: nil, deleted: false) ⇒ void
This method returns an undefined value.
Create a history item for the setting.
74 75 76 77 78 |
# File 'lib/super_settings/storage.rb', line 74 def create_history(key:, changed_by:, created_at:, value: nil, deleted: false) # :nocov: raise NotImplementedError # :nocov: end |
#destroy_all ⇒ Object
Implementing classes can override this method to delete all settings. This is used for testing purposes.
106 107 |
# File 'lib/super_settings/storage.rb', line 106 def destroy_all end |
#find_by_key(key) ⇒ SuperSetting::Setting::Storage
Storage classes must implement this method to return a settings by it’s key.
55 56 57 58 59 |
# File 'lib/super_settings/storage.rb', line 55 def find_by_key(key) # :nocov: raise NotImplementedError # :nocov: end |
#last_updated_at ⇒ Time
Storage classes must implement this method to return most recent time that any setting was updated.
65 66 67 68 69 |
# File 'lib/super_settings/storage.rb', line 65 def last_updated_at # :nocov: raise NotImplementedError # :nocov: end |
#load_asynchronous? ⇒ Boolean
Return true if it’s safe to load setting asynchronously in a background thread.
97 98 99 |
# File 'lib/super_settings/storage.rb', line 97 def load_asynchronous? !!(@load_asynchronous.nil? ? default_load_asynchronous? : @load_asynchronous) end |
#transaction(&block) ⇒ void
This method returns an undefined value.
Implementing classes can override this method to wrap an operation in an atomic transaction.
90 91 92 |
# File 'lib/super_settings/storage.rb', line 90 def transaction(&block) yield end |
#updated_since(timestamp) ⇒ Array<SuperSetting::Setting::Storage>
Storage classes must implement this method to return all settings updates since the specified timestamp.
46 47 48 49 50 |
# File 'lib/super_settings/storage.rb', line 46 def updated_since() # :nocov: raise NotImplementedError # :nocov: end |
#with_connection(&block) ⇒ void
This method returns an undefined value.
Implementing classes can override this method to setup a thread safe connection within a block.
83 84 85 |
# File 'lib/super_settings/storage.rb', line 83 def with_connection(&block) yield end |