Sha256: a697628575320677dd34b094286e9974bd5106f01f93508b787c1eaa3d7bddc9
Contents?: true
Size: 1.57 KB
Versions: 7
Compression:
Stored size: 1.57 KB
Contents
module RevelryData module Resource extend ActiveSupport::Concern include JSONAPI::ActsAsResourceController included do respond_to :html, :json, :props before_filter :setup_request end def new process_request_operations end def setup_request @request = JSONAPI::Request.new(params, { context: context, key_formatter: key_formatter }) render_errors(@request.errors) unless @request.errors.empty? rescue => e handle_exceptions(e) end def fmt_is_json_api? request.format == 'json' end def setup_response return unless fmt_is_json_api? if response.body.size > 0 response.headers['Content-Type'] = JSONAPI::MEDIA_TYPE end end def render_results(operation_results) response_doc = create_response_document(operation_results) respond_with response_doc.contents do |fmt| fmt.html do @json_api = response_doc.contents render status: response_doc.status end fmt.json do render json: response_doc.contents, status: response_doc.status end fmt.props do render json: response_doc.contents, status: response_doc.status end end end def base_response_meta { current_user: current_user, csrf_token: form_authenticity_token, current_org: current_user.try(:org), flashes: flash, } end end end
Version data entries
7 entries across 7 versions & 1 rubygems