Module: ActsAsApi::RailsRenderer

Defined in:
lib/acts_as_api/rails_renderer.rb

Overview

Contains rails specific renderers used by acts_as_api to render a jsonp response

See ActsAsApi::Config about the possible configurations

Class Method Summary (collapse)

Class Method Details

+ (Object) setup



7
8
9
10
11
12
13
14
# File 'lib/acts_as_api/rails_renderer.rb', line 7

def self.setup
  ActionController.add_renderer :acts_as_api_jsonp do |json, options|
    json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)
    json = "#{options[:callback]}(#{json}, #{response.status})" unless options[:callback].blank?
    self.content_type ||= Mime::JSON
    self.response_body = json
  end
end