Class: MR::Factory::ModelFactory::Config

Inherits:
Object
  • Object
show all
Includes:
WithAssociationsConfig
Defined in:
lib/mr/factory/model_factory.rb

Instance Method Summary collapse

Instance Method Details

#ar_association_for(model, name) ⇒ Object



87
88
89
90
91
# File 'lib/mr/factory/model_factory.rb', line 87

def ar_association_for(model, name)
  if (reflection = model.record_class.reflect_on_association(name))
    model.record.association(reflection.name)
  end
end

#build_associated_model(association_name, record_class) ⇒ Object



79
80
81
# File 'lib/mr/factory/model_factory.rb', line 79

def build_associated_model(association_name, record_class)
  self.factory_for(association_name, record_class).model
end

#build_associated_record(association_name, record_class) ⇒ Object



83
84
85
# File 'lib/mr/factory/model_factory.rb', line 83

def build_associated_record(association_name, record_class)
  self.build_associated_model(association_name, record_class).record
end