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 9145925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:38:03+00:00 2026-06-17T10:38:03+00:00

I am using a third party library (gem) to instantiate two versions of the

  • 0

I am using a third party library (gem) to instantiate two versions of the same Class. The gem’s documentation instantiates the Class

client.sobject_module = My::Module
client.materialize("Contact") #=> My::Module::Contact 

And my code does this.

client.sobject_module = MyModule
client.materialize("Contact")

The module itself is empty

module MyModule 
end

There are two versions of the same code, yet when I do

MyModule::Contact.find("John")

for instance it appears the Contact got materialed into the global namespace. This is a materialize method that gets called from the gem

def materialize(classnames)
  classes = (classnames.is_a?(Array) ? classnames : [classnames]).collect do |clazz|
    original_classname = clazz
    clazz = original_classname[0,1].capitalize + original_classname[1..-1]
    unless const_defined_in_module(module_namespace, clazz)
      new_class = module_namespace.const_set(clazz,  Class.new(Databasedotcom::Sobject::Sobject))
      new_class.client = self
      new_class.materialize(original_classname)
      new_class
    else
      module_namespace.const_get(clazz)
    end
  end
  classes.length == 1 ? classes.first : classes
end

client on the new_class appears to get set correctly, but when I do

MyModule::Contact.client  

it returns the same client as

MyModule1::Contact.client 

I have spent days trying to figure this out any pointers will be helpful. The gem I am using is this.

  • 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-06-17T10:38:04+00:00Added an answer on June 17, 2026 at 10:38 am

    I just released a wrapper around the gem that let’s you walk around this issue.
    It works kinda like:

    Databasedotcom::Isolated.perform(options) do
      # Constants are materialized automatically
      contact = Contact.last  
    
      # Work with them as needed
      puts contact.inspect
    end
    
    # And everything get's cleaned up behind you.
    defined? Contact # => nil
    

    It’s currently on an early stage but I hope it suit’s your needs.
    The source is available at https://github.com/sagmor/databasedotcom-isolated

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

Sidebar

Related Questions

I'm using a third party library class that has the following (abbreviated) method: public
I'm using a third party library which has a blocking function, that is, it
I am using some third party library to connect to a server via async
I am using a third party library to do hand evaluation of 7 card
I Am using a third party library in one of my .NET projects. I
I am attempting to set up my own project using a third party library
I'm using a third party static library in my C++ project that has a
My code is using a third party library that employ a singleton pattern deep
I'm using a third party library to render an image to a GDI DC
I am using a third party library that provide some callbacks for a widget,

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.