webget_ramp 1.7.1.6 → 1.7.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,8 @@ module ActiveRecord::SaveExtensions
5
5
  # This solves an issue we found with Rails associations not saving.
6
6
  #
7
7
  # By Andrew Carpenter (acarpen@wested.org)
8
+ #
9
+ # Deprecated, superceded by #save_redux!
8
10
 
9
11
  def save_false_then_reload!
10
12
  transaction do
@@ -15,5 +17,19 @@ module ActiveRecord::SaveExtensions
15
17
  return true
16
18
  end
17
19
 
20
+
21
+ # Save the record without validation, then reload, then save with validtion.
22
+ # This ensure that rails brings back the correct associations to validate.
23
+ # This solves an issue we found with Rails associations not saving.
24
+
25
+ def save_redux!
26
+ transaction do
27
+ save(false)
28
+ reload
29
+ save!
30
+ end
31
+ return true
32
+ end
33
+
18
34
  end
19
35
  ActiveRecord::Base.send(:include, ActiveRecord::SaveExtensions)
@@ -126,7 +126,33 @@ class Hash
126
126
  # Hash#pivot aggregates values for a hash of hashes,
127
127
  # for example to calculate subtotals and groups.
128
128
  #
129
- # Example:
129
+ # Suppose you have data arranged by companies, roles, and headcounts.
130
+
131
+ # data = {
132
+ # "Apple" => {"Accountants" => 11, "Designers" => 22, "Developers" => 33},
133
+ # "Goggle" => {"Accountants" => 44, "Designers" => 55, "Developers" => 66},
134
+ # "Microsoft" => {"Accountants" => 77, "Designers" => 88, "Developers" => 99},
135
+ # }
136
+ #
137
+ # To calculate each company's total headcount, you pivot up, then sum:
138
+ #
139
+ # data.pivot(:up,&:sum)
140
+ # => {
141
+ # "Apple"=>66,
142
+ # "Goggle"=>165,
143
+ # "Microsoft"=>264
144
+ # }
145
+ #
146
+ # To calculate each role's total headcount, you pivot down, then sum:
147
+ #
148
+ # data.pivot(:down,&:sum)
149
+ # => {
150
+ # "Accountants"=>132,
151
+ # "Designers"=>165,
152
+ # "Developers"=>198
153
+ # }
154
+ #
155
+ # Generic xxample:
130
156
  # h={
131
157
  # "a"=>{"x"=>1,"y"=>2,"z"=>3},
132
158
  # "b"=>{"x"=>4,"y"=>5,"z"=>6},
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webget_ramp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1.6
4
+ version: 1.7.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - WebGet
@@ -32,7 +32,7 @@ cert_chain:
32
32
  DXnLFY0cVuBnNDMOOFl8vk1qIcZjcTovhzgcixpG6Uk5qmUsKHRLQf4oQJx7TfLK
33
33
  -----END CERTIFICATE-----
34
34
 
35
- date: 2009-12-10 00:00:00 -08:00
35
+ date: 2009-12-15 00:00:00 -08:00
36
36
  default_executable:
37
37
  dependencies: []
38
38
 
metadata.gz.sig CHANGED
Binary file