Class: Cockroach::FactoryGirl::Node
- Inherits:
-
Base::Node
- Object
- Base::Node
- Cockroach::FactoryGirl::Node
- Defined in:
- lib/cockroach/fixtures/factory_girl/node.rb
Overview
Node deals only with a specific records class. It makes sure that fixtures are created specific amount of time and will make sure that the associations are correctly assigned.
Constant Summary
Constants inherited from Base::Node
Instance Attribute Summary
Attributes inherited from Base::Node
#approach, #ids, #name, #source
Instance Method Summary collapse
Methods inherited from Base::Node
#amount, extract_info, #initialize, #node_name, valid_structure?
Methods included from Base::NodeStructure
Constructor Details
This class inherits a constructor from Cockroach::Base::Node
Instance Method Details
#after_initialize ⇒ Object
7 8 9 |
# File 'lib/cockroach/fixtures/factory_girl/node.rb', line 7 def after_initialize @factory = ::FactoryGirl.factory_by_name(@name) end |
#load!(factory_opts = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cockroach/fixtures/factory_girl/node.rb', line 11 def load! factory_opts = nil if factory_opts normalised_opts = factory_opts.dup @aliases.each_pair { |k,v| normalised_opts[k] = normalised_opts.delete(v) } if @aliases normalised_opts.keep_if {|k,v| .include? k } end amount.times do current_factory = generate_current_factory(normalised_opts) ids << current_factory.id unless nodes.blank? load_nodes! (factory_opts || {}).merge({ node_name => current_factory}) end end end |