Sha256: 00f5386edc51f916b3689b9104ebef2344eb193b8e999c4d3671db23a078c2a3
Contents?: true
Size: 1.36 KB
Versions: 6
Compression:
Stored size: 1.36 KB
Contents
class Gon module Jbuilder class << self def handler(args, global = false) options = parse_options_from args valid_options? options, global controller = Gon::EnvFinder.controller_env(options) controller_name = global ? '' : controller.controller_path parser = Gon::Jbuilder::Parser.new( template_path: Gon::EnvFinder.template_path(options, 'jbuilder'), controller: controller, controller_name: controller_name, locals: options[:locals] ) data = parser.parse! [data, options] end private def valid_options?(options, global) if global && !options[:template] raise 'You should provide :template when use jbuilder with global variables' end end def parse_options_from(args) if old_api? args text = "[DEPRECATION] view_path argument is now optional. " text << "If you need to specify it, " text << "please use gon.jbuilder(:template => 'path')" warn text args.extract_options!.merge(:template => args[0]) elsif new_api? args args.first else {} end end def old_api?(args) args.first.is_a? String end def new_api?(args) args.first.is_a? Hash end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
gon-6.4.0 | lib/gon/jbuilder.rb |
gon-6.3.2 | lib/gon/jbuilder.rb |
gon-6.3.1 | lib/gon/jbuilder.rb |
gon-6.2.1 | lib/gon/jbuilder.rb |
gon-6.2.0 | lib/gon/jbuilder.rb |
gon-6.1.0 | lib/gon/jbuilder.rb |