Sha256: c64148480baf8d958e4114697ecfa3b2a779bef923926cbb2629e84b8f878fd5
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 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 rabl 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gon-6.0.1 | lib/gon/jbuilder.rb |
gon-6.0.0 | lib/gon/jbuilder.rb |