Sha256: cc660f5a1f6793956cb02f02fb79748939250095f3d10307a1b1951df757eb00

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
luruju-0.2.0 lib/luruju/jude_api_loader_in_cruby.rb