Skip to content

Instantly share code, notes, and snippets.

@chrismytton
Created June 10, 2012 18:25
Show Gist options
  • Save chrismytton/2906829 to your computer and use it in GitHub Desktop.
Save chrismytton/2906829 to your computer and use it in GitHub Desktop.
require 'execjs'
class SgNodeMapper
def method_missing(method, *args, &block)
context.call("nodemapper.#{method.to_s.camelize(:lower)}", *args)
end
private
def context
@context ||= ExecJS.compile(source)
end
def source
@source ||= File.read(source_path)
end
def source_path
Rails.root.join('vendor', 'sg_node_mapper', 'nodemapper.js')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment