Sha256: eb0d128c0e2420670fe2ca50a454ab816ff12b58175a4136f9845362fde5c49d

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

module ActsAsApi
  # Contains rails specific renderers used by acts_as_api to render a jsonp response
  #
  # See ActsAsApi::Config about the possible configurations
  module RailsRenderer
    def self.setup
      ActionController.add_renderer :acts_as_api_jsonp do |json, options|
        json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)

        if options[:callback].present?
          json = "#{options[:callback]}(#{json}, #{response.status})"
          self.content_type = Mime[:js]
        end

        self.response_body = json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_api-1.0.1 lib/acts_as_api/rails_renderer.rb
acts_as_api-1.0.0 lib/acts_as_api/rails_renderer.rb