lib/jcompiler/provider.rb in jcompiler-0.1.108 vs lib/jcompiler/provider.rb in jcompiler-0.1.109
- old
+ new
@@ -1,8 +1,20 @@
class Jcompiler::Provider
- def array!(arr, &block)
+ def object!(arg_name = nil, &block)
+ srcs, subst_src = if arg_name
+ [block.call(nil), "#{block.parameters[0][1]}=#{arg_name};"]
+ else
+ [block.call, '']
+ end
+ %{"{\#{#{subst_src}[#{srcs.join(',')}].join(',')}}"}
+ end
+
+ def array!(arg_name, &block)
item_name = block.parameters[0][1].to_s
- #src = block.call(item_name)
- #'"[#{eval(arr.to_s)}]"'
- %{"[\#{#{arr}.map { |#{item_name}| brand.id }.join(',')}]"}
+ src = block.call(nil)
+ %{"[\#{#{arg_name}.map { |#{item_name}| #{src} }.join(',')}]"}
+ end
+
+ def integer!(i)
+ %{"#{i}"}
end
end