ohm 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/ohm.rb +10 -1
  2. data/test/model.rb +8 -0
  3. metadata +12 -31
data/lib/ohm.rb CHANGED
@@ -142,7 +142,6 @@ module Ohm
142
142
 
143
143
  # Wraps the whole pipelining functionality.
144
144
  module PipelinedFetch
145
- private
146
145
  def fetch(ids)
147
146
  arr = db.pipelined do
148
147
  ids.each { |id| db.hgetall(namespace[id]) }
@@ -814,6 +813,16 @@ module Ohm
814
813
  end
815
814
  end
816
815
 
816
+ # Retrieve a set of models given an array of IDs.
817
+ #
818
+ # Example:
819
+ #
820
+ # User.fetch([1, 2, 3])
821
+ #
822
+ def self.fetch(ids)
823
+ all.fetch(ids)
824
+ end
825
+
817
826
  # Index any method on your model. Once you index a method, you can
818
827
  # use it in `find` statements.
819
828
  def self.index(attribute)
@@ -371,6 +371,14 @@ test "find all" do
371
371
  assert all.detect {|e| e.name == "Ruby Tuesday" }
372
372
  end
373
373
 
374
+ # Fetching
375
+ test "fetch ids" do
376
+ event1 = Event.create(:name => "A")
377
+ event2 = Event.create(:name => "B")
378
+
379
+ assert_equal [event1, event2], Event.fetch([event1.id, event2.id])
380
+ end
381
+
374
382
  # Sorting
375
383
  test "sort all" do
376
384
  Person.create :name => "D"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-20 00:00:00.000000000 Z
14
+ date: 2012-08-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: redis
18
- requirement: !ruby/object:Gem::Requirement
18
+ requirement: &2152402160 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,15 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ! '>='
30
- - !ruby/object:Gem::Version
31
- version: '0'
26
+ version_requirements: *2152402160
32
27
  - !ruby/object:Gem::Dependency
33
28
  name: nest
34
- requirement: !ruby/object:Gem::Requirement
29
+ requirement: &2152401480 !ruby/object:Gem::Requirement
35
30
  none: false
36
31
  requirements:
37
32
  - - ~>
@@ -39,15 +34,10 @@ dependencies:
39
34
  version: '1.0'
40
35
  type: :runtime
41
36
  prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
37
+ version_requirements: *2152401480
48
38
  - !ruby/object:Gem::Dependency
49
39
  name: scrivener
50
- requirement: !ruby/object:Gem::Requirement
40
+ requirement: &2152400640 !ruby/object:Gem::Requirement
51
41
  none: false
52
42
  requirements:
53
43
  - - ~>
@@ -55,15 +45,10 @@ dependencies:
55
45
  version: 0.0.3
56
46
  type: :runtime
57
47
  prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
- requirements:
61
- - - ~>
62
- - !ruby/object:Gem::Version
63
- version: 0.0.3
48
+ version_requirements: *2152400640
64
49
  - !ruby/object:Gem::Dependency
65
50
  name: cutest
66
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &2152400100 !ruby/object:Gem::Requirement
67
52
  none: false
68
53
  requirements:
69
54
  - - ~>
@@ -71,12 +56,7 @@ dependencies:
71
56
  version: '1.1'
72
57
  type: :development
73
58
  prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ~>
78
- - !ruby/object:Gem::Version
79
- version: '1.1'
59
+ version_requirements: *2152400100
80
60
  description: Ohm is a library that allows to store an object in Redis, a persistent
81
61
  key-value database. It includes an extensible list of validations and has very good
82
62
  performance.
@@ -135,8 +115,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
115
  version: '0'
136
116
  requirements: []
137
117
  rubyforge_project: ohm
138
- rubygems_version: 1.8.23
118
+ rubygems_version: 1.8.11
139
119
  signing_key:
140
120
  specification_version: 3
141
121
  summary: Object-hash mapping library for Redis.
142
122
  test_files: []
123
+ has_rdoc: