active-fedora 7.0.3 → 7.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_fedora/associations/collection_association.rb +8 -0
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/relation.rb +3 -2
- data/lib/active_fedora/relation/query_methods.rb +26 -0
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/has_many_associations_spec.rb +6 -0
- data/spec/integration/scoped_query_spec.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e75a0408125225a3ef0ae91e7de53d0560d10a6
|
4
|
+
data.tar.gz: 56de97df291d2239583e16c500f99ab26df355af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3df7b3a6fd7aab417e3c10d589e0fc06bba37cbee05400ea9d4983314cdaf191239b54ed9202a38f75ce1d1e5dbf1b03ec74b60a0ded41856ac3f68c140fdf31
|
7
|
+
data.tar.gz: d43e9f106e4b6f2c59eb12e36fe62c03d0e1b0040f60af2d373247aa25143499c1ce163ae39b75b3de353301a10abcc6535a01ad9e26c2085c0726dff4bd4c9e
|
@@ -3,7 +3,7 @@ module ActiveFedora
|
|
3
3
|
extend Deprecation
|
4
4
|
self.deprecation_horizon = 'active-fedora version 8.0.0'
|
5
5
|
|
6
|
-
delegate :find, :first, :exists?, :where, :limit, :order, :delete_all,
|
6
|
+
delegate :find, :first, :exists?, :where, :limit, :offset, :order, :delete_all,
|
7
7
|
:destroy_all, :count, :last, :find_with_conditions, :find_in_batches, :find_each, :to=>:all
|
8
8
|
|
9
9
|
def self.extended(base)
|
@@ -54,6 +54,7 @@ module ActiveFedora
|
|
54
54
|
return @records if loaded?
|
55
55
|
args = @klass == ActiveFedora::Base ? {:cast=>true} : {}
|
56
56
|
args[:rows] = limit_value if limit_value
|
57
|
+
args[:start] = offset_value if offset_value
|
57
58
|
args[:sort] = order_values if order_values
|
58
59
|
|
59
60
|
@records = to_enum(:find_each, where_values, args).to_a
|
@@ -121,7 +122,7 @@ module ActiveFedora
|
|
121
122
|
|
122
123
|
private
|
123
124
|
|
124
|
-
VALID_FIND_OPTIONS = [:order, :limit, :conditions, :cast]
|
125
|
+
VALID_FIND_OPTIONS = [:order, :limit, :start, :conditions, :cast]
|
125
126
|
|
126
127
|
def apply_finder_options(options)
|
127
128
|
relation = clone
|
@@ -131,7 +132,7 @@ module ActiveFedora
|
|
131
132
|
finders = options.dup
|
132
133
|
finders.delete_if { |key, value| value.nil? && key != :limit }
|
133
134
|
|
134
|
-
([:order,:limit] & finders.keys).each do |finder|
|
135
|
+
([:order,:limit,:start] & finders.keys).each do |finder|
|
135
136
|
relation = relation.send(finder, finders[finder])
|
136
137
|
end
|
137
138
|
|
@@ -37,6 +37,15 @@ module ActiveFedora
|
|
37
37
|
@values[:limit] = value
|
38
38
|
end
|
39
39
|
|
40
|
+
def offset_value
|
41
|
+
@values[:offset]
|
42
|
+
end
|
43
|
+
|
44
|
+
def offset_value=(value)
|
45
|
+
raise ImmutableRelation if loaded?
|
46
|
+
@values[:offset] = value
|
47
|
+
end
|
48
|
+
|
40
49
|
# Limits the returned records to those that match the provided search conditions
|
41
50
|
#
|
42
51
|
# @option [Hash] opts a hash of solr conditions
|
@@ -97,6 +106,23 @@ module ActiveFedora
|
|
97
106
|
self
|
98
107
|
end
|
99
108
|
|
109
|
+
# Start the returned records at an offset position.
|
110
|
+
# Useful for paginated results
|
111
|
+
#
|
112
|
+
# @option [Integer] value the number of records offset
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
# Person.where(name_t: 'Jones').offset(1000)
|
116
|
+
# => [#<Person @id="foo:123" @name='Jones'>, #<Person @id="foo:125" @name='Jones'>, ...]
|
117
|
+
def offset(value)
|
118
|
+
spawn.offset!(value)
|
119
|
+
end
|
120
|
+
|
121
|
+
def offset!(value)
|
122
|
+
self.offset_value = value
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
100
126
|
def none! # :nodoc:
|
101
127
|
extending!(NullRelation)
|
102
128
|
end
|
@@ -21,6 +21,7 @@ describe "Collection members" do
|
|
21
21
|
expect(library.books).not_to be_loaded
|
22
22
|
expect(library.books.size).to eq(0)
|
23
23
|
expect(library.books).to be_loaded
|
24
|
+
expect(library.books.any?).to be_false
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -50,6 +51,11 @@ describe "Collection members" do
|
|
50
51
|
it "should load from solr with options" do
|
51
52
|
expect(library.books.load_from_solr(rows: 0).size).to eq(0)
|
52
53
|
end
|
54
|
+
it "should respond to #any?" do
|
55
|
+
expect(library.books.any?).to be_true
|
56
|
+
expect(library.books.any? {|book| book.library == nil}).to be_false
|
57
|
+
expect(library.books.any? {|book| book.library == library}).to be_true
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
@@ -76,6 +76,9 @@ describe "scoped queries" do
|
|
76
76
|
it "should limit" do
|
77
77
|
ModelIntegrationSpec::Basic.limit(1).should == [test_instance1]
|
78
78
|
end
|
79
|
+
it "should offset" do
|
80
|
+
ModelIntegrationSpec::Basic.offset(1).should == [test_instance2, test_instance3]
|
81
|
+
end
|
79
82
|
|
80
83
|
it "should chain queries" do
|
81
84
|
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [test_instance2]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|