require 'base64' module Luruju class JudeApiLoader def self.load jude_file, options={} dto = unmarshal send("access_jruby_using_#{Luruju.config.access_jruby_with.to_s}", jude_file, options) raise dto.exception if dto.exception JudeMeta.instance= dto.meta dto.meta.define_all dto.model end def self.access_jruby_using_drb jude_file, options LurujuClient.new.marshal jude_file, options end def self.access_jruby_using_command jude_file, options encoded_options = Base64.encode64(Marshal.dump(options)).gsub(/\n/,' ') %x{jruby #{luruju_bin 'access_jruby_with_command.rb'} #{jude_file} #{encoded_options}} end def self.unmarshal marshaled Marshal.load(Base64.decode64(marshaled)) rescue ArgumentError => e define_dummy_jude_class(e.message.split(' ').last.split('::').last) retry end def self.define_dummy_jude_class const_name return if /Methods$/ =~ const_name JudeApi.module_eval "class #{const_name} < JudeBase ; end" end end end