hash_all 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/hash_all.gemspec +2 -27
- data/lib/hash_all/version.rb +1 -1
- metadata +3 -3
data/hash_all.gemspec
CHANGED
@@ -11,33 +11,8 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://blog.mekdigital.com"
|
12
12
|
s.summary = %q{Wrapper for find(:all) that returns Hash}
|
13
13
|
s.description = <<-EOF
|
14
|
-
|
15
|
-
|
16
|
-
objects injected into a Hash. The attribute used as a key for the Hash should be
|
17
|
-
specified as first argument. if :fetch is not specified in the arguments the whole
|
18
|
-
object will be assigned as value, otherwise only the attribute spefified.
|
19
|
-
You can pass in all the same arguments to this method as you can to <tt>find(:all)</tt>.
|
20
|
-
|
21
|
-
Example
|
22
|
-
|
23
|
-
Given the models:
|
24
|
-
|
25
|
-
Feed(id: integer, state: string, name: string)
|
26
|
-
Post(id: integer, feed_name: string, title: string, url: string)
|
27
|
-
|
28
|
-
count the number of posts of every state. Row count is too high to use SQL JOIN.
|
29
|
-
|
30
|
-
@post_per_state = {}
|
31
|
-
feeds = Feed.hash_all('feed_name', :fetch => 'state')
|
32
|
-
posts = Post.all(:select => 'COUNT(id), feed_name',
|
33
|
-
:group => 'feed_name')
|
34
|
-
posts.each do |p|
|
35
|
-
@post_per_state[feeds[p.feed_name]] ||= 0
|
36
|
-
@post_per_state[feeds[p.feed_name]] += p.attributes['COUNT(id)'].to_i
|
37
|
-
end
|
38
|
-
|
39
|
-
=> {"new york"=>6, "georgia"=>11, "new mexico"=>2, ... }
|
40
|
-
|
14
|
+
Wrapper/helper for ActiveRecord find(:all, *args).\n
|
15
|
+
Returns a collection of objects injected into a Hash.
|
41
16
|
EOF
|
42
17
|
|
43
18
|
s.rubyforge_project = "hash_all"
|
data/lib/hash_all/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 1
|
9
|
+
version: 2.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Emanuele Tozzato
|
@@ -18,7 +18,7 @@ date: 2011-03-30 00:00:00 -07:00
|
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description: "
|
21
|
+
description: " Wrapper/helper for ActiveRecord find(:all, *args).\n\n Returns a collection of objects injected into a Hash. \n"
|
22
22
|
email: etozzato@gmail.com
|
23
23
|
executables: []
|
24
24
|
|