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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daf0d3e0301711dd16f05d1c7b9fcb29661ad8d0
4
- data.tar.gz: dc1dd7e060dd3e0a266087a93ebd3af7f0762ab3
3
+ metadata.gz: 01e34e0a18e5eadb5b2b85752b06cb819ce8df8f
4
+ data.tar.gz: b20729b4a93638e07e055e5d78f7f9f8e44f8632
5
5
  SHA512:
6
- metadata.gz: e3b0fad1dadabc01cd4ee52ce597cb8189e582f00c054a385888a1acc13c7cfb0be1b94454d809f6c34f54e36195d62abd6142fafdaf0f54a98d2b0926a88e42
7
- data.tar.gz: 582349ba8daee47b23e8d12c87cecda58237dcdaf5ff3e0130af8fbf49a6775cfa8248c7dcc99958b5ff595a9c5a16746ba3909b520aa607b79cd2b2dcfc1819
6
+ metadata.gz: 327e539a3ae432ddcac979044933aa22e94bdc978130967ee51327ab7652214ffbaf4ac524c57ba302e1936457120b22d54bd6d6020d25b1245cfff9596f1503
7
+ data.tar.gz: 4214282db7150b1e235f99e8b91c8b453549bb89390aae0af2db2dc6cb404a597725fdb59d027a5d1e71a109c08cfab93fff2d799a17a5cfe38b9a71e39a1223
@@ -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(property_name)
16
+ def where(arguments)
17
17
  query_proxy = OData::Model::QueryProxy.new(self)
18
- query_proxy.where(property_name.to_sym)
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 property_name [Symbol]
21
+ # @param argument [Hash,to_sym]
22
22
  # @return [self]
23
23
  # @api private
24
- def where(property_name)
25
- @last_criteria = query[target.property_map[property_name]]
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
 
@@ -1,5 +1,5 @@
1
1
  module OData
2
2
  module Model
3
- VERSION = '0.5.15'
3
+ VERSION = '0.5.16'
4
4
  end
5
5
  end
@@ -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
- let(:subject) { query_proxy.where(:name) }
16
+ context 'with a symbol' do
17
+ let(:subject) { query_proxy.where(:name) }
17
18
 
18
- it { expect(subject).to be_a(OData::Model::QueryProxy) }
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
- it 'sets up last criteria properly' do
21
- expect(subject.last_criteria).to be_a(OData::Query::Criteria)
22
- expect(subject.last_criteria.property).to eq(Product.property_map[:name])
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.15
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-16 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler