lib/jcompiler/provider.rb in jcompiler-0.1.109 vs lib/jcompiler/provider.rb in jcompiler-0.1.110
- old
+ new
@@ -1,12 +1,19 @@
class Jcompiler::Provider
+ def initialize
+ @context = nil
+ end
+
def object!(arg_name = nil, &block)
+ pre_context = context
+ context = []
srcs, subst_src = if arg_name
[block.call(nil), "#{block.parameters[0][1]}=#{arg_name};"]
else
[block.call, '']
end
+ context = pre_context
%{"{\#{#{subst_src}[#{srcs.join(',')}].join(',')}}"}
end
def array!(arg_name, &block)
item_name = block.parameters[0][1].to_s
@@ -15,6 +22,14 @@
end
def integer!(i)
%{"#{i}"}
end
+
+ def method_missing(name, *args, &block)
+ context << %{"\\"#{name}\\":3"}
+ end
+
+ private
+
+ attr_accessor :context
end