I'm building an application that will be hosted both as a stand-alone app as well as running within the web browser. This means that certain classes should be implemented differently (but used in the same way). Example:
If OPAL_RB
require 'javascript_aware_lib'
else
require 'native_lib'
end
The problem with this is, Ruby will evaluate this at run-time, but Opal will evaluate it at compile time. If this was not so, I could simply use a rescue clause:
begin
RUBY_ENGINE_VERSION
#opal requires goes here
rescue
# MRI Ruby requires goes here
end
So, to put things simply: Is there any kind of directive or work-around to keep Opal from evaluating a block of code? Thanks.