Class: SolidObserver::Services::CableOperations
- Inherits:
-
Object
- Object
- SolidObserver::Services::CableOperations
- Defined in:
- lib/solid_observer/services/cable_operations.rb
Constant Summary collapse
- MESSAGES =
{ trim: { success: "Expired/trimmable Solid Cable messages trimmed.", failure: "Cable trim failed. No raw Cable payloads or adapter details are shown. Use solid_observer:cable:trim if the problem continues." }.freeze, unavailable: "Cable controls are unavailable because Solid Cable support is disabled or not detected." }.freeze
Class Method Summary collapse
- .available? ⇒ Boolean
- .message(operation, key = nil) ⇒ Object
- .trim ⇒ Object
- .unavailable_message ⇒ Object
Instance Method Summary collapse
Class Method Details
.available? ⇒ Boolean
15 16 17 |
# File 'lib/solid_observer/services/cable_operations.rb', line 15 def available? new.available? end |
.message(operation, key = nil) ⇒ Object
23 24 25 26 27 |
# File 'lib/solid_observer/services/cable_operations.rb', line 23 def (operation, key = nil) return MESSAGES.fetch(:unavailable) if operation == :unavailable MESSAGES.fetch(operation).fetch(key) end |
.trim ⇒ Object
19 20 21 |
# File 'lib/solid_observer/services/cable_operations.rb', line 19 def trim new.trim end |
.unavailable_message ⇒ Object
29 30 31 |
# File 'lib/solid_observer/services/cable_operations.rb', line 29 def (:unavailable) end |
Instance Method Details
#available? ⇒ Boolean
34 35 36 |
# File 'lib/solid_observer/services/cable_operations.rb', line 34 def available? SolidObserver.config.solid_cable_enabled? && !!defined?(::SolidCable::Message) end |
#trim ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/solid_observer/services/cable_operations.rb', line 38 def trim = self.class return {ok: false, message: .} unless available? perform_operation( :trim, success_message: .(:trim, :success), failure_message: .(:trim, :failure) ) do end end |