Class: Cockroach::FactoryGirl::Profiler

Inherits:
Object
  • Object
show all
Includes:
Base::LoadNodes, Base::NodeStructure
Defined in:
lib/cockroach/fixtures/factory_girl/profiler.rb

Overview

Profiler does all the routine to fill the database.

Instance Method Summary collapse

Methods included from Base::NodeStructure

#[]

Constructor Details

#initialize(config = Cockroach.config) ⇒ Profiler

Returns a new instance of Profiler.



10
11
12
13
# File 'lib/cockroach/fixtures/factory_girl/profiler.rb', line 10

def initialize config = Cockroach.config
  @source = config.profile
  @base_models = @source.keys
end

Instance Method Details

#loadObject

This method will load all the mentioned records into database



16
17
18
19
20
21
22
23
24
25
# File 'lib/cockroach/fixtures/factory_girl/profiler.rb', line 16

def load
  unless @loaded
    Cockroach::FactoryGirl::Loader.load
    @source.each_pair do |name, structure|
      node = Cockroach::FactoryGirl::Node.new(name, structure)
      nodes[node.node_name] = node
    end
    @loaded = true
  end
end

#load!Object

This method will load all the mentioned records into database



28
29
30
31
# File 'lib/cockroach/fixtures/factory_girl/profiler.rb', line 28

def load!
  load unless @loaded
  nodes.each_value(&:load!)
end