Module: BrowsingHistory::Storage::ConfigureMethods
- Defined in:
- lib/browsing_history/storage.rb
Instance Attribute Summary collapse
-
#current_storage_type ⇒ Object
readonly
Returns the value of attribute current_storage_type.
Instance Method Summary collapse
- #attach_storage(storage_type, **opts) ⇒ Object
- #current_storage ⇒ Object
- #init_storages ⇒ Object
- #storages ⇒ Object
Instance Attribute Details
#current_storage_type ⇒ Object (readonly)
Returns the value of attribute current_storage_type.
13 14 15 |
# File 'lib/browsing_history/storage.rb', line 13 def current_storage_type @current_storage_type end |
Instance Method Details
#attach_storage(storage_type, **opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/browsing_history/storage.rb', line 23 def attach_storage(storage_type, **opts) storage = storages[storage_type] if storage storage.connect(opts) @current_storage_type = storage_type else raise InvalidStorage end end |
#current_storage ⇒ Object
15 16 17 |
# File 'lib/browsing_history/storage.rb', line 15 def current_storage storages[current_storage_type] end |
#init_storages ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/browsing_history/storage.rb', line 34 def init_storages BrowsingHistory.storage_types.each do |key| storages[key] = "BrowsingHistory::Storages::#{key.to_s.camelize}".constantize end raise StoragesNotSet if storages.empty? attach_storage(storages.keys.first) end |
#storages ⇒ Object
19 20 21 |
# File 'lib/browsing_history/storage.rb', line 19 def storages @storages ||= {} end |