File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,13 @@ def set_variable(name, value)
6464
6565 %w( rabl jbuilder ) . each do |builder_name |
6666 define_method builder_name do |*options |
67- if options . length >= 2
67+ if options . first . is_a? String
6868 warn "[DEPRECATION] view_path argument is now optional. If you need to specify it please use #{ builder } (:template => 'path')"
6969 options = options . extract_options! . merge ( :template => options [ 0 ] )
70- else
70+ elsif options . first . is_a? Hash
7171 options = options ? options . first : { }
72+ else
73+ raise ArgumentError . new ( "You pass wrong argument type to template generator method: #{ options . first . class . to_s } " )
7274 end
7375
7476 builder_module = get_builder ( builder_name )
@@ -86,18 +88,21 @@ def set_variable(name, value)
8688 end
8789 end
8890 end
89-
9091 alias_method :orig_jbuilder , :jbuilder
9192
9293 def jbuilder ( *options )
9394 raise NoMethodError . new ( 'You can use Jbuilder support only in 1.9+' ) if RUBY_VERSION !~ /9/
94- orig_jbuilder ( options )
95+ orig_jbuilder ( * options )
9596 end
9697
97-
9898 private
99+
99100 def get_builder ( builder_name )
100- "Gon::#{ builder_name . classify } " . constantize rescue raise NoMethodError . new ( "You should define #{ builder_name . classify } in your Gemfile" )
101+ begin
102+ "Gon::#{ builder_name . classify } " . constantize
103+ rescue
104+ raise NoMethodError . new ( "You should define #{ builder_name . classify } in your Gemfile" )
105+ end
101106 end
102107
103108 def get_controller ( options )
You can’t perform that action at this time.
0 commit comments