Ruby on Rails Saturday, January 29, 2011

Hi there,

I have a class which looks like this:

class EventRoster{
@events = []
@event_occurrences = []
}

@events is an array of Event which contains various information about a
financial event on a calendar (title, amount, date etc). This 'event'
may repeat (weekly for example) but I don't want to make a copy of the
entire event with a new date for every single instance. (This calendar
could span 20 years)

I have thus created @event_occurrences which is an array of objects that
simply hold their 'parent' Event#object_id and a date.

I want to be able to loop over all the event_occurrences and access the
data of the parent event. At the moment I'm doing this via something
like:

ObjectSpace._id2ref(@parent_event_object_id).title

but this is sometimes returning RangeError(xxx is a recycled object).
Assumedly the parent objects are being garbage collected.

Does anybody have any suggestions on how this could be done correctly?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment