Object
# File lib/less/java_script/rhino_context.rb, line 17 def self.instance return new # NOTE: for Rhino a context should be kept open per thread ! end
# File lib/less/java_script/rhino_context.rb, line 21 def initialize(globals = nil) @rhino_context = Rhino::Context.new :java => true if @rhino_context.respond_to?(:version) @rhino_context.version = '1.8' apply_1_8_compatibility! if @rhino_context.version.to_s != '1.8' else apply_1_8_compatibility! end globals.each { |key, val| @rhino_context[key] = val } if globals end
# File lib/less/java_script/rhino_context.rb, line 52 def call(properties, *args) options = args.last.is_a?(::Hash) ? args.pop : {} # extract_option! source_name = options[:source_name] || "<eval>" line_number = options[:line_number] || 1 @rhino_context.eval(properties, source_name, line_number).call(*args) rescue Rhino::JSError => e handle_js_error(e) end
# File lib/less/java_script/rhino_context.rb, line 42 def eval(source, options = {}) source = source.encode('UTF-8') if source.respond_to?(:encode) source_name = options[:source_name] || "<eval>" line_number = options[:line_number] || 1 @rhino_context.eval("(#{source})", source_name, line_number) rescue Rhino::JSError => e handle_js_error(e) end
# File lib/less/java_script/rhino_context.rb, line 36 def exec(&block) @rhino_context.open(&block) rescue Rhino::JSError => e handle_js_error(e) end
Generated with the Darkfish Rdoc Generator 2.