Module: DaddysGirl::AssociationModel
- Defined in:
- lib/daddys_girl.rb
Instance Method Summary collapse
- #generate(attributes = {}) ⇒ Object
- #generate!(attributes = {}) ⇒ Object
- #spawn(attributes = {}) ⇒ Object
- #target_class_symbol ⇒ Object
Instance Method Details
#generate(attributes = {}) ⇒ Object
34 35 36 37 |
# File 'lib/daddys_girl.rb', line 34 def generate(attributes = {}) attributes = attributes.merge(association_attribute) FactoryGirl.create(target_class_symbol, attributes) end |
#generate!(attributes = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/daddys_girl.rb', line 39 def generate!(attributes = {}) attributes = attributes.merge(association_attribute) FactoryGirl.create(target_class_symbol, attributes).tap do |obj| raise obj.errors.inspect unless obj.errors.empty? end end |
#spawn(attributes = {}) ⇒ Object
46 47 48 49 |
# File 'lib/daddys_girl.rb', line 46 def spawn(attributes = {}) attributes = attributes.merge(association_attribute) FactoryGirl.build(target_class_symbol, attributes) end |
#target_class_symbol ⇒ Object
30 31 32 |
# File 'lib/daddys_girl.rb', line 30 def target_class_symbol self.symbol end |