lib/ice.rb in ice-0.2.4 vs lib/ice.rb in ice-0.3.0

- old
+ new

@@ -1,51 +1,11 @@ -require 'rubygems' -require 'v8' +require 'ice' +require 'ice/cubeable' +require 'ice/cube_association' +require 'ice/base_cube' +require 'ice/base' -class Object - def to_ice - nil - end -end +require 'rails' -[FalseClass, TrueClass, Numeric, String].each do |cls| - cls.class_eval do - def to_ice - self - end - end -end - -class Array - def to_ice - map &:to_ice - end -end - -class Hash - def to_ice - res = {} - each_pair do |key,value| - res[key] = value.to_ice - end - res - end -end - - - module Ice - def self.convert_template(template_text, vars = {}) - - V8::Context.new do |cxt| - cxt.load "#{File.dirname(__FILE__)}/parser.js" - - vars.each_pair do |key, value| - cxt[key] = value.to_ice - end - - jst = cxt['Jst'] - return @evaled = jst.evaluate(jst.compile(template_text), {}) - end - end + require 'ice/railtie' if defined?(Rails) end -