In Files

Gon::Base

Constants

ENV_CONTROLLER_KEY

Public Class Methods

get_controller(options = {}) click to toggle source
# File lib/gon/base.rb, line 31
def get_controller(options = {})
  options[:controller] ||
    (
      current_gon &&
      current_gon.env[Gon::Base::ENV_CONTROLLER_KEY] ||
      current_gon.env['action_controller.rescue.response'].
        instance_variable_get('@template').
        instance_variable_get('@controller')
    )
end
get_template_path(options, extension) click to toggle source
# File lib/gon/base.rb, line 42
def get_template_path(options, extension)
  if options[:template]
    if right_extension?(extension, options[:template])
      options[:template]
    else
      [options[:template], extension].join('.')
    end
  else
    controller = get_controller(options).controller_path
    action = get_controller(options).action_name
    "app/views/#{controller}/#{action}.json.#{extension}"
  end
end
render_data(options) click to toggle source
# File lib/gon/base.rb, line 7
def render_data(options)
  namespace, tag, cameled, camel_depth, watch, type, cdata, global_root, namespace_check = parse_options(options)
  script = namespace_check ? "window.#{namespace}=window.#{namespace}||{};" : "window.#{namespace}={};"

  script << formatted_data(namespace, cameled, camel_depth, watch, global_root)
  script = Gon::Escaper.escape_unicode(script)
  script = Gon::Escaper.javascript_tag(script, type, cdata) if tag

  script.html_safe
end
render_data_amd(options) click to toggle source
# File lib/gon/base.rb, line 18
def render_data_amd(options)
  namespace, tag, cameled, camel_depth, watch, type, cdata, global_root = parse_options(options)

  script = "define('#{namespace}',[],function(){" 
  script << amd_formatted_data(namespace, cameled, camel_depth, watch, global_root)
  script << 'return gon;});'

  script = Gon::Escaper.escape_unicode(script)
  script = Gon::Escaper.javascript_tag(script, type, cdata) if tag

  script.html_safe
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.