Class: RailsSpotlight::Middlewares::Handlers::BaseActionHandler
- Inherits:
-
Object
- Object
- RailsSpotlight::Middlewares::Handlers::BaseActionHandler
- Defined in:
- lib/rails_spotlight/middlewares/handlers/base_action_handler.rb
Direct Known Subclasses
CodeAnalysisActionHandler, ConsoleActionHandler, DirectoryIndexActionHandler, FileActionHandler, MetaActionHandler, NotFoundActionHandler, SqlActionHandler, VerifyActionHandler
Constant Summary collapse
- BaseError =
Class.new(StandardError) do attr_reader :code, :status def initialize( = nil, code: nil) super() @code = code @status = case self.class.name.demodulize.underscore when 'unsupported_media_type' then 415 when 'not_found' then 404 when 'unprocessable_entity' then 422 when 'forbidden' then 403 else 500 end end end
- UnsupportedMediaType =
Class.new(BaseError)
- NotFound =
Class.new(BaseError)
- UnprocessableEntity =
Class.new(BaseError)
- Forbidden =
Class.new(BaseError)
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(request_id, request, content_type) ⇒ BaseActionHandler
constructor
A new instance of BaseActionHandler.
Constructor Details
#initialize(request_id, request, content_type) ⇒ BaseActionHandler
Returns a new instance of BaseActionHandler.
27 28 29 30 31 |
# File 'lib/rails_spotlight/middlewares/handlers/base_action_handler.rb', line 27 def initialize(request_id, request, content_type) @request_id = request_id @request = request @content_type = content_type end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
33 34 35 |
# File 'lib/rails_spotlight/middlewares/handlers/base_action_handler.rb', line 33 def content_type @content_type end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
33 34 35 |
# File 'lib/rails_spotlight/middlewares/handlers/base_action_handler.rb', line 33 def request @request end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
33 34 35 |
# File 'lib/rails_spotlight/middlewares/handlers/base_action_handler.rb', line 33 def request_id @request_id end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rails_spotlight/middlewares/handlers/base_action_handler.rb', line 35 def call validate_data_access! if data_access_token validate_project! unless skip_project_validation? execute response rescue BaseError => e error_response(e) rescue => e # rubocop:disable Style/RescueStandardError error_response(BaseError.new(e.)) end |