class RablToJbuilder::SimpleTransformer
Public Instance Methods
rewrite_call(exp)
click to toggle source
# File lib/rabl_to_jbuilder/transformer.rb, line 124 def rewrite_call(exp) _, target, meth, *args = exp return exp unless target.nil? if meth == :object || meth == :collection empty elsif meth == :attributes raise "called attributes before declaring `object` or `collection`" unless @object s(:call, json, nil, @object, *args) elsif meth == :attribute raise "called attributes before declaring `object` or `collection`" unless @object # FIXME: options hash and conditions s(:call, json, args[0][1], s(:call, @object, args[0][1])) elsif meth == :extends if @object raise "extends must take a string" unless args[0][0] == :str template = args[0][1] variable = File.basename(File.dirname(args[0][1])).singularize locals_hash = s(:hash, s(:lit, variable.to_sym), @object) s(:call, json, :partial!, args[0], locals_hash) else s(:call, json, :partial!, args[0]) end else exp end end