odata-model 0.5.15 → 0.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/odata/model/query.rb +3 -3
- data/lib/odata/model/query_proxy.rb +10 -3
- data/lib/odata/model/version.rb +1 -1
- data/spec/model/query_proxy_spec.rb +20 -5
- 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: 01e34e0a18e5eadb5b2b85752b06cb819ce8df8f
|
4
|
+
data.tar.gz: b20729b4a93638e07e055e5d78f7f9f8e44f8632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 327e539a3ae432ddcac979044933aa22e94bdc978130967ee51327ab7652214ffbaf4ac524c57ba302e1936457120b22d54bd6d6020d25b1245cfff9596f1503
|
7
|
+
data.tar.gz: 4214282db7150b1e235f99e8b91c8b453549bb89390aae0af2db2dc6cb404a597725fdb59d027a5d1e71a109c08cfab93fff2d799a17a5cfe38b9a71e39a1223
|
data/lib/odata/model/query.rb
CHANGED
@@ -11,11 +11,11 @@ module OData
|
|
11
11
|
# Methods mixed in at the class level.
|
12
12
|
module ClassMethods
|
13
13
|
# Starts a query chain with a filter for a given property's name.
|
14
|
-
# @param property_name [to_sym]
|
14
|
+
# @param property_name [Hash,to_sym]
|
15
15
|
# @return [OData::Model::Query]
|
16
|
-
def where(
|
16
|
+
def where(arguments)
|
17
17
|
query_proxy = OData::Model::QueryProxy.new(self)
|
18
|
-
query_proxy.where(
|
18
|
+
query_proxy.where(arguments)
|
19
19
|
end
|
20
20
|
|
21
21
|
# Starts a query chain with a limit to entities returned.
|
@@ -18,11 +18,18 @@ module OData
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Sets up a new criteria for filters for the given property name.
|
21
|
-
# @param
|
21
|
+
# @param argument [Hash,to_sym]
|
22
22
|
# @return [self]
|
23
23
|
# @api private
|
24
|
-
def where(
|
25
|
-
|
24
|
+
def where(argument)
|
25
|
+
if argument.is_a?(Hash)
|
26
|
+
argument.each do |property_name, value|
|
27
|
+
self.where(property_name.to_sym).is(eq: value)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
@last_criteria = query[target.property_map[argument.to_sym]]
|
31
|
+
end
|
32
|
+
|
26
33
|
self
|
27
34
|
end
|
28
35
|
|
data/lib/odata/model/version.rb
CHANGED
@@ -13,13 +13,28 @@ describe OData::Model::QueryProxy do
|
|
13
13
|
|
14
14
|
it { expect(subject).to respond_to(:where) }
|
15
15
|
describe '#where' do
|
16
|
-
|
16
|
+
context 'with a symbol' do
|
17
|
+
let(:subject) { query_proxy.where(:name) }
|
17
18
|
|
18
|
-
|
19
|
+
it { expect(subject).to be_a(OData::Model::QueryProxy) }
|
20
|
+
|
21
|
+
it 'sets up last criteria properly' do
|
22
|
+
expect(subject.last_criteria).to be_a(OData::Query::Criteria)
|
23
|
+
expect(subject.last_criteria.property).to eq(Product.property_map[:name])
|
24
|
+
end
|
25
|
+
end
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
|
27
|
+
context 'with a hash' do
|
28
|
+
let(:subject) { query_proxy.where(name: 'Bread') }
|
29
|
+
|
30
|
+
it { expect(subject).to be_a(OData::Model::QueryProxy) }
|
31
|
+
|
32
|
+
it 'sets up last criteria properly' do
|
33
|
+
expect(subject.last_criteria).to be_a(OData::Query::Criteria)
|
34
|
+
expect(subject.last_criteria.property).to eq(Product.property_map[:name])
|
35
|
+
expect(subject.last_criteria.operator).to eq(:eq)
|
36
|
+
expect(subject.last_criteria.value).to eq('Bread')
|
37
|
+
end
|
23
38
|
end
|
24
39
|
end
|
25
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odata-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|