medea 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,6 +49,19 @@ module Medea
49
49
  #return self, so that we can chain up query refinements
50
50
  self
51
51
  end
52
+
53
+ def limit n
54
+ self.filters[:TOP] = n
55
+ end
56
+
57
+ def limit= n
58
+ limit n
59
+ end
60
+
61
+ #synonym for limit
62
+ def top n
63
+ limit n
64
+ end
52
65
  #end query interface
53
66
 
54
67
  def add_data_filter property, value
@@ -78,6 +91,8 @@ module Medea
78
91
  filter_array << URI.escape("#{name.to_s}=#{field.to_s}:#{value.to_s}", unsafe)
79
92
  end
80
93
  end
94
+ else
95
+ filter_array << URI.escape("#{name.to_s}=#{val.to_s}", unsafe)
81
96
  end
82
97
  end
83
98
  end
@@ -20,8 +20,13 @@ module Medea
20
20
 
21
21
  #create a JasonDeferredQuery with no conditions, other than HTTP_X_CLASS=self.name
22
22
  #if mode is set to :eager, we create the JasonDeferredQuery, invoke it's execution and then return it
23
- def JasonObject.all(mode=:lazy)
24
- JasonDeferredQuery.new :class => self, :filters => {:VERSION0 => nil, :FILTER => {:HTTP_X_CLASS => self, :HTTP_X_ACTION => :POST}}
23
+ def JasonObject.all(opts=nil)
24
+ q = JasonDeferredQuery.new :class => self, :filters => {:VERSION0 => nil, :FILTER => {:HTTP_X_CLASS => self, :HTTP_X_ACTION => :POST}}
25
+ if opts && opts[:limit]
26
+ q.limit = opts[:limit]
27
+ end
28
+
29
+ q
25
30
  end
26
31
 
27
32
  #here we will capture:
@@ -1,5 +1,5 @@
1
1
  module Medea
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
 
4
4
  #When the templates are changed, this version should be incremented
5
5
  #This version is used when uploading/updating the templates
@@ -2,9 +2,35 @@ require "spec_helper"
2
2
 
3
3
  describe "Deferred Query" do
4
4
 
5
+ before :all do
6
+ @userlist = []
7
+ 10.times do |i|
8
+ u = User.new
9
+ u.name = "Person#{i}"
10
+ u.save!
11
+ @userlist << u
12
+ end
13
+ end
14
+
15
+ after :all do
16
+ @userlist.each do |u|
17
+ u.delete!
18
+ end
19
+ end
20
+
5
21
  it "should be enumerable" do
6
22
  for u in User.all
7
-
8
23
  end
9
24
  end
25
+
26
+ it "should be able to be limited to a certain number of results" do
27
+ u = User.all
28
+ u.limit = 5
29
+ u.count.should be <= 5
30
+
31
+ u = User.all :limit => 4
32
+ u.count.should be <= 4
33
+ end
34
+
35
+ it "should be able to fetch those since a particular time"
10
36
  end
Binary file
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 3
9
- version: 0.6.3
8
+ - 4
9
+ version: 0.6.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Jensen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-02 00:00:00 +11:00
17
+ date: 2011-02-03 00:00:00 +11:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency