Hey, I need advice with dealing with non-Active Record collections and making them available as a method on another object.
Note no ActiveRecord models are being used here.
I have a really simple class:
it holds on to an array of other models and that collection is given a name.
class MultiOptionPlan include ActiveModel::Model attr_accessor :plans, :name end
What I want to do is pass this collection into another class and make it available as a method with its name.
class PlansTable include ActiveModel::Model attr_accessor :multi_option_plans, :plans end
What I want:
table = PlansTable.new(multi_option_plans: MultiOptionPlan.new(plans: foo_plans, name: "foo")) table.foo => foo_plans
I could do have MultiOptionPlan assign it self to its table via instance_eval, or I could override missing_method on the table class, to select the multi_option_plan with the desired name. Looking for best approach.