Thibaud Renaux Thibaud Renaux - 1 year ago 86
Ruby Question

Ruby sub-oject with dynamics presence of fields

I quite new ruby (rails) developer and I need to interface a complex object behavior. I'll try to explain as much as I can.

I've an object A in which I would like to contains an array of entities(B) which have a boolean base and a type. If this boolean is true some other properties can be set (and input fields can be showed in dashboard).

I don't really want to create a separate object(B).

I know I could use
but don't know if it's usable.

By the way the array of B entities could be initialized when creating A object depends on A params and B type.

So my questions are:

  • Is it better to use a separate object or a
    entities for B ?

  • How could I manage other B params depends on type?

I hope it's understandable.


Answer Source

I will create these classes in aim to manage them all specifically Thanks all !

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download