0

I want to build a structure of nested objects without creating models for each of them. This structure should be used for intermediate calculations, for display purposes only and not persist in database.

What is the right Rails-way to make object with array of nested objects inside?

Could be models created without intention to persist in database? Is this the right way to create objects?

Ruby is dynamic-typed language. How to limit objects in the nested array to specific class only?

As I understand, attr_accessor is an equivalent to object's field in other programming languages. How to declare that this field should be of specific class type only?

Paul
  • 25,812
  • 38
  • 124
  • 247
  • ruby is less concerned with an objects type, you should care if the object can respond to methods you want to call on it, i.e. `list << o if o.respond_to?(:foo)` – house9 May 12 '12 at 16:47

1 Answers1

0

You can take a look at http://datamapper.org/

Its should be able to do what you are looking for

Yuriy Goldshtrakh
  • 2,014
  • 1
  • 11
  • 7