Sha256: 5124c41ac0c6c54e850325c16f864710925689e55b9f7f514fca7add346d7cb7

Contents?: true

Size: 605 Bytes

Versions: 4

Compression:

Stored size: 605 Bytes

Contents

module Transponder
  module Transmission
    extend ActiveSupport::Concern

    included do 
      after_filter :intercept_js

      def xms_errors object, message: nil
        render json: { errors: (message || object.errors), 
                       controller: controller_name, 
                       action: action_name, 
                       namespace: params[:controller].split('/')[0] }, status: :unprocessable_entity
      end

      def intercept_js
        if request.format == :js
          response.header['Content-Type'] = "application/transmission"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
transponder-0.9.3 lib/transponder/transmission.rb
transponder-0.9.2 lib/transponder/transmission.rb
transponder-0.9.0 lib/transponder/transmission.rb
transponder-0.8.2 lib/transponder/transmission.rb