Class: RailsSpotlight::Channels::Handlers::LogsHandler
- Inherits:
-
Object
- Object
- RailsSpotlight::Channels::Handlers::LogsHandler
- Defined in:
- lib/rails_spotlight/channels/handlers/logs_handler.rb
Constant Summary collapse
- TYPE =
'logs'
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(data) ⇒ LogsHandler
constructor
A new instance of LogsHandler.
- #project ⇒ Object
- #raise_project_mismatch_error!(for_project) ⇒ Object
Constructor Details
#initialize(data) ⇒ LogsHandler
Returns a new instance of LogsHandler.
9 10 11 |
# File 'lib/rails_spotlight/channels/handlers/logs_handler.rb', line 9 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/rails_spotlight/channels/handlers/logs_handler.rb', line 13 def data @data end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rails_spotlight/channels/handlers/logs_handler.rb', line 15 def call return unless ::RailsSpotlight.config.live_logs_enabled? return unless data['type'] == TYPE for_project = Array(data['project']) raise_project_mismatch_error!(for_project) if for_project.present? && !for_project.include?(project) { payload: data[:payload] } end |
#project ⇒ Object
32 33 34 |
# File 'lib/rails_spotlight/channels/handlers/logs_handler.rb', line 32 def project ::RailsSpotlight.config.project_name end |
#raise_project_mismatch_error!(for_project) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/rails_spotlight/channels/handlers/logs_handler.rb', line 25 def raise_project_mismatch_error!(for_project) raise ::RailsSpotlight::Channels::Handlers::ResponseError.new( "Project mismatch, Logs from #{for_project} project cannot be forwarded in #{project} project", code: :project_mismatch ) end |