Created
June 10, 2012 18:25
-
-
Save chrismytton/2906829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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