The following example fails
class A
class B
end
end
p Object.const_get 'A' # => A
p Object.const_get 'A::B' # => NameError: wrong constant name A::B
UPDATE
Questions about the topic asked earlier:
Cast between String and Classname
Ruby String#to_class
Get a class by name in Ruby?
The last one gives a nice solution which can...
Hi folks,
I am facing some strange issue, I have a user table(use class) and a country table(country class). An user may have N number of countries. Hence, I have added a List of countries in the user class with the getter and setter method. In the table I have made the country_id as foreign key in user table. And, I have a @OneToMany o...
I want to do something like Object.prototype.dataTransfer = new DataTransfer();, but I want every new object to have it's own dataTransfer. How do I do this?
For example, if I do
var a = new Object();
var b = new Object();
Object.prototype.dataTransfer = new Object();
a.dataTransfer.prop = 1;
b.dataTransfer.prop = 2;
I want a.dataT...
I have a business object representing an invoice with all its line items, contractor data, bank account number, etc.
I want to be able to display such an invoice and allow user to edit it, for instance to add new line item or delete an exisiting one. User should see all properties of an invoice.
What's the best way about it?
Should I...
Hey guys,
I know there are a lot of questions on this topic already, but it is just not clear to me yet.
So, what I am still wondering about is, if I call a method and pass it an object, do I then have to retain this object inside my method to use it there. And if I retain it, where do I release it. Lets make a bit of a more complex exam...
So far all the zoom of magnifying plugins I have found are for images and I need something that will work when hovered over an embedded object tag .pdf file. Any ideas?
...
class A(object):
def __init__(self):
self.db = create_db_object()
def change_Db_a(self):
self.db.change_something()
self.db.save()
def change_db_b(self):
self.db.change_anotherthing()
self.db.save()
I am getting object from database, I changing it in multiple function and saving...
What is the exact difference between object pool and connection pool? Is there any difference to in their algorithm for utilizing memory.
msdn says "Object pooling lets you control the number of connections you use, as opposed to connection pooling, where you control the maximum number reached."
What exactly this mean?
Please help me ...
When we want to create only one object of class, we use singleton design pattern. I want to create maximum 3 or 5 objects of my class. Is there any way to restrict maximum number of object creation in Java?
...
Say you are adding x number of objects to a collection, and after or before adding them to a collection you are modifying the objects attributes. When would you add the element to the collection before or after the object has been modified.
Option A)
public static void addToCollection(List<MyObject> objects) {
MyObject newObject = ...
I'm working in a C# codebase that has a class hierarchy:
class Animal { Animal prey; }
class Mammal : Animal { Mammal[] livesAmicablyWith; }
class Lion : Mammal { }
Forgive the stupid example.
I would like to repurpose this class hierarchy for something representable in the same exact object format, but which requires more data. In ...
Ok, I have a question.
I have 3-tier project. Dal => Domain => UI.
design choice is not to expose domain objects (business classes) to the ui, but to use DTO.
I am trying to build a Query engine that takes parameters from the ui layer and converts into the NHibernate criteria api on the dal layer. The point is the ui layer does not known...
Hi,
I having a problem in my website where I have 2 objects held in session, both object are structured differently and do not have any links to each other (not intentionally). Both objects however, have a collection of "Travellers". What I am trying to do is modify one collection by adding or removing "Travellers", when a finish button...
With a single property this is fairly easy:
var jsonobj = {
"test": "ok"
}
var propname = "test";
// Will alert "ok"
alert(jsonobj[propname]);
But what I want to do is use a nested property:
var jsonobj = {
"test": {
"test2": "ok"
}
}
var propname = "test.test2";
// Alerts undefined
alert(jsonobj[propname]);
I...
I want to use the value of a variable as an "index" of an object, an of a value inside of it.
Unfortunately this code won't run.
animatedObjects = {
userPosition.uid: {
"uid": userPosition.uid,
"x": 30,
"y": 31
}
}
Wher...
OK, I always get confused about this.
Let's say I have this code.
Public Sub Bar(byRef pMap as clsMap)
Dim foo as new FooClass()
pMap.listOfFoo.Add(foo)
end Sub
This would mean that referencing 'Foo' or the item stored in 'listOfFoo' would reference the same object, right? If I was to change a property of 'foo' - but not change it t...
I'm creating a module that let's you define some extra options for categorys in Magento, following this tuturial to get started: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module
I built on a skeleton module created with ModuleCreator.
I have ...
I'm trying to build something (ultimately a gem but for now an application) that works as follows.
Suppose for example the DB records are breeds of dog. There's a Dog parent class and a child class for each breed. The actual breeds aren't known until runtime.
When the server begins it will load up records from the DB and instantiate ...
Hi, first question here, apologies in advance for any foul-ups.
I'm implementing an interpreter for a toy language in C#, and in order to do math in that language I'd like to implement a function like this:
public static object Add( object a, object b )
{
// return the sum of a and b
// each might be int, double, or one of many oth...
I am creating a map for my roguelike game and already I stumbled on a problem. I want to create a two dimensional array of objects. In my previous C++ game I did this:
class tile; //found in another file.
tile theMap[MAP_WIDTH][MAP_HEIGHT];
I can't figure out how I should do this with Ruby.
...