Class: Seedy::AbstractGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/seedy/graphs/abstract_graph.rb

Direct Known Subclasses

SimpleGraph

Constant Summary collapse

{
  :teams => 0,
  :accounts => 0,
  :bugs => 0,
  :calls => 0,
  :cases => 0,
  :contacts => 0,
 	:documents=> 0,
  :emails => 0,    
 	:email_addresses => 0,
  :leads => 0,
  :meetings => 0,
  :notes => 0,
  :opportunities => 0,
  :products => 0,
  :product_bundles => 0,
  :quotes => 0,
  :tasks => 0,
}
@@records =
{}
@@buffer =
Seedy::AbstractBuffer

Instance Method Summary collapse

Instance Method Details

#add(mod, id) ⇒ Object

Adds an ID to the id array



27
28
29
30
# File 'lib/seedy/graphs/abstract_graph.rb', line 27

def add(mod,id)
  @@records[mod] = [] unless @@records[mod].class == Array
  @@records[mod] << id
end

#bufferObject

Our buffer



42
43
44
# File 'lib/seedy/graphs/abstract_graph.rb', line 42

def buffer
  @@buffer
end

#create_accountsObject



62
63
64
65
66
67
68
69
# File 'lib/seedy/graphs/abstract_graph.rb', line 62

def create_accounts
  mod = :accounts
  records[mod].times {        
     = Accounts.build(select(:users),select(:teams))
    buffer << 
    add(mod, .id)
  }      
end

#create_bugsObject



71
72
73
74
75
76
77
78
# File 'lib/seedy/graphs/abstract_graph.rb', line 71

def create_bugs
  mod = :bugs
  records[mod].times {        
    bug = Bugs.build(select(:users),select(:teams), select(:accounts))
    buffer << bug
    add(mod, bug.id)
  }      
end

#create_callsObject



116
117
118
119
120
121
122
123
# File 'lib/seedy/graphs/abstract_graph.rb', line 116

def create_calls
  mod = :calls
  records[mod].times {        
    call = Calls.build(select(:users),select(:teams), select(:contacts))
    buffer << call
    add(mod, call.id)
  }      
end

#create_casesObject



89
90
91
92
93
94
95
96
# File 'lib/seedy/graphs/abstract_graph.rb', line 89

def create_cases
  mod = :cases
  records[mod].times {        
    cases = Cases.build(select(:users),select(:teams), select(:accounts))
    buffer << cases
    add(mod, cases.id)
  }      
end

#create_contactsObject



80
81
82
83
84
85
86
87
# File 'lib/seedy/graphs/abstract_graph.rb', line 80

def create_contacts
  mod = :contacts
  records[mod].times {        
    contact = Contacts.build(select(:users),select(:teams), select(:accounts))
    buffer << contact
    add(mod, contact.id)
  }      
end

#create_email_addressesObject



134
135
136
137
138
139
140
141
# File 'lib/seedy/graphs/abstract_graph.rb', line 134

def create_email_addresses
  mod = :email_addresses
  records[mod].times {        
    email = EmailAddresses.build()
    buffer << email
    add(mod, email.id)
  }      
end

#create_emailsObject



125
126
127
128
129
130
131
132
# File 'lib/seedy/graphs/abstract_graph.rb', line 125

def create_emails
  mod = :emails
  records[mod].times {        
    email = Emails.build(select(:users),select(:teams))
    buffer << email
    add(mod, email.id)
  }      
end

#create_leadsObject



107
108
109
110
111
112
113
114
# File 'lib/seedy/graphs/abstract_graph.rb', line 107

def create_leads
  mod = :leads
  records[mod].times {        
    lead = Leads.build(select(:users),select(:teams), select(:contacts), select(:opportunities), select(:accounts))
    buffer << lead
    add(mod, lead.id)
  }      
end

#create_opportunitiesObject



98
99
100
101
102
103
104
105
# File 'lib/seedy/graphs/abstract_graph.rb', line 98

def create_opportunities
  mod = :opportunities
  records[mod].times {        
    opp = Opportunities.build(select(:users),select(:teams), select(:accounts))
    buffer << opp
    add(mod, opp.id)
  }      
end

#create_teamsObject



53
54
55
56
57
58
59
60
# File 'lib/seedy/graphs/abstract_graph.rb', line 53

def create_teams
  mod = :teams
  records[mod].times {        
    team = Teams.build(select(:users))
    buffer << team
    add(mod, team.id)
  }
end

#create_user(offset) ⇒ Object



46
47
48
49
50
51
# File 'lib/seedy/graphs/abstract_graph.rb', line 46

def create_user(offset)
  user = Users.build(offset)
  puts user.to_sql
  buffer << user
  add(:users, user)
end

#recordsObject



37
38
39
# File 'lib/seedy/graphs/abstract_graph.rb', line 37

def records
  @@related_records
end

#select(mod) ⇒ Object

Selects a random ID from the id array for a given module



33
34
35
# File 'lib/seedy/graphs/abstract_graph.rb', line 33

def select(mod)
  @@records[mod][rand(@@records[mod].length - 1)]
end