Class: Seedy::AbstractGraph
- Inherits:
-
Object
- Object
- Seedy::AbstractGraph
- Defined in:
- lib/seedy/graphs/abstract_graph.rb
Direct Known Subclasses
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
-
#add(mod, id) ⇒ Object
Adds an ID to the id array.
-
#buffer ⇒ Object
Our buffer.
- #create_accounts ⇒ Object
- #create_bugs ⇒ Object
- #create_calls ⇒ Object
- #create_cases ⇒ Object
- #create_contacts ⇒ Object
- #create_email_addresses ⇒ Object
- #create_emails ⇒ Object
- #create_leads ⇒ Object
- #create_opportunities ⇒ Object
- #create_teams ⇒ Object
- #create_user(offset) ⇒ Object
- #records ⇒ Object
-
#select(mod) ⇒ Object
Selects a random ID from the id array for a given module.
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 |
#buffer ⇒ Object
Our buffer
42 43 44 |
# File 'lib/seedy/graphs/abstract_graph.rb', line 42 def buffer @@buffer end |
#create_accounts ⇒ Object
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 { account = Accounts.build(select(:users),select(:teams)) buffer << account add(mod, account.id) } end |
#create_bugs ⇒ Object
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_calls ⇒ Object
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_cases ⇒ Object
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_contacts ⇒ Object
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_addresses ⇒ Object
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_emails ⇒ Object
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_leads ⇒ Object
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_opportunities ⇒ Object
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_teams ⇒ Object
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 |
#records ⇒ Object
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 |