Feature Requests: Browse | Submit New | Admin

[#28236] Ordering objects in hash elements

Date:
2010-05-23 12:29
Priority:
3
Submitted By:
Pavel Vondricka (wanthalf)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Ordering objects in hash elements

Detailed description
Just one idea for your consideration...

For my project I needed some way to keep and manage arbitrary order of objects in a hash-element, which is reflected
in the order as the objects appear in the XML. I did a very straightforward hack to the code, which you won't like,
but I enclose it for illustration. It takes care of the order when reading/writing hashes of object nodes, in case the
objects have attribute accessor called "_xml_position"  (being a plain integer) defined. Maybe the capability
and the name of the attribute should be rather configurable?

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-06-10 18:03
Sender: Pavel Vondricka

Right. But I also need to be able to change the order
manually at any time.
Date: 2010-05-23 19:34
Sender: Olaf Klischat

...also, hashes seem to be insertion-ordered in 1.9, so people
could just wait for 1.9 support :-P
Date: 2010-05-23 19:27
Sender: Olaf Klischat

I would probably prefer to allow the user to specify the class
of the hash attribute to be created (defaulting to Hash), so
the user can supply a hash class there that remembers the insertion
order of its elements (and reproduces it when #each_pair is called
on it).
Date: 2010-05-23 12:33
Sender: Pavel Vondricka

Sorry, it did not upload the attachment...

Attached Files:

Name Description Download
standard_nodes-0.9.1.patch Diff for standard_nodes.rb v0.9.1 Download

Changes:

Field Old Value Date By
File Added4942: standard_nodes-0.9.1.patch2010-05-23 12:33wanthalf