Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6537277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:35:52+00:00 2026-05-25T10:35:52+00:00

I have this idea for a client/server archetype where the server would hold a

  • 0

I have this idea for a client/server archetype where the server would hold a hash of Marshal.dump’ed class objects along with their version numbers. Then the client could query the server concerning the version number and import the newer version of the class before instantiating it:

class Stuff
  def methods
    gibberish
  end
end

$obj_hash["Stuff"] = [3.0, Marshal.dump(Stuff)]

The problem I’m running into is that Ruby doesn’t seem to want to allow me to Marshal.load the data once I’ve downloaded it from the server because the class and its methods don’t exist in the client. If I bypass this by creating a ‘dummy’ class I’m then unable to replace the dummy class with the Marshal.load’ed data. If I simply try to use the loaded data as a class it functions according to the contents of the dummy class rather than the downloaded one.

Is there another way to go about this? If not then I guess I could just gz the code and then eval it at the other end, but I’m trying to avoid using eval or sending easily decipherable code over the line.

Thanks in advance for any advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:35:53+00:00Added an answer on May 25, 2026 at 10:35 am

    Look at what happens.

    class Stuff
      def methods
        "foo"
      end
    end
    
    ruby-1.8.7-p352 :001 > Marshal.dump(Stuff) 
     => "\004\bc\bStuff"
    

    Notice how it says nothing about “methods” or “foo.” If the server isn’t sending that code down the wire, how is the client supposed to know what Stuff#methods should do?

    It won’t. 🙂

    To do what you want to do, you’ll have to send down the code itself and eval it. You’ll have to implement the versioning logic yourself, of course, and “really re-define” the classes (not just monkey-patch) them.

    See are you allowed to redefine a class in ruby? or is this just in irb

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no idea if this is possible, but if it is, what would
I have no idea if this is possible ... but it would be cool.
I have a client and a server I want to send objects from client
I have this idea for a free backup application. The largest problem I need
I have this grand idea to basically employ some brute force attack to test/verify
What is the purpose of annotations in Java? I have this fuzzy idea of
I have a html like this: The idea is that divs are floated left
I have no idea why this is happening. I have some very straightforward code,
I have no idea why this doesn't work, but doing some validation functions and
I have no idea what this means. But here is the code that it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.