odata-model 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/odata/model/attributes.rb +1 -1
- data/lib/odata/model/configuration.rb +8 -0
- data/lib/odata/model/query_proxy.rb +11 -0
- data/lib/odata/model/version.rb +1 -1
- data/lib/odata/model.rb +2 -2
- data/odata-model.gemspec +2 -1
- data/spec/example_models/odatademo_limited_product.rb +13 -0
- data/spec/model/active_model_lint_spec.rb +1 -0
- data/spec/model/query_proxy_spec.rb +6 -0
- data/spec/spec_helper.rb +1 -0
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 995370eea78ea8a601aa51f63c24d4c5b44ca21f
|
4
|
+
data.tar.gz: 8407abe05108d9cd8ea77715de0b34feb45d0256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83cbbcb630063ab7b5ea5b09842890da0e2bbbad209904f44118e7c7acd4b923b62c176e7fbe9e3795cf9d776fcc1d0d171f8e5f3c17112a8f376c0373673c80
|
7
|
+
data.tar.gz: 43e2eabce06e6bf56c687ba98714263943673aafc1bf15abe967fcded63f7681c6d5da38907373565be0ff141ba8f30edfd5e9b4567513e504883e695819ab6c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.4.0
|
4
|
+
|
5
|
+
* Removed strict dependency on ActiveModel.
|
6
|
+
* Added `limit_default_selection` setting to limit default queries to only the
|
7
|
+
supplied properties of a model.
|
8
|
+
|
3
9
|
## 0.3.0
|
4
10
|
|
5
11
|
* Added OData::Model::Railtie for Ruby on Rails integration.
|
@@ -70,6 +70,14 @@ module OData
|
|
70
70
|
nil
|
71
71
|
end
|
72
72
|
|
73
|
+
# Sets the configuration option to cause a select operation to be set
|
74
|
+
# by default that only queries for the properties defined in the model.
|
75
|
+
#
|
76
|
+
# @return [nil]
|
77
|
+
def limit_default_selection
|
78
|
+
odata_config[:limit_default_selection] = true
|
79
|
+
end
|
80
|
+
|
73
81
|
# Get the OData::Service
|
74
82
|
# @return [OData::Service]
|
75
83
|
# @api private
|
@@ -14,6 +14,7 @@ module OData
|
|
14
14
|
@target = model_class
|
15
15
|
@query = target.odata_entity_set.query
|
16
16
|
@last_criteria = nil
|
17
|
+
set_default_select
|
17
18
|
end
|
18
19
|
|
19
20
|
# Sets up a new criteria for filters for the given property name.
|
@@ -80,9 +81,19 @@ module OData
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
84
|
+
# By default we only select the properties defined on the Model.
|
85
|
+
# @api private
|
86
|
+
def set_default_select
|
87
|
+
if target.odata_config[:limit_default_selection]
|
88
|
+
query.select(target.property_map.values)
|
89
|
+
end
|
90
|
+
self
|
91
|
+
end
|
92
|
+
|
83
93
|
private
|
84
94
|
|
85
95
|
attr_reader :target, :query
|
96
|
+
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|
data/lib/odata/model/version.rb
CHANGED
data/lib/odata/model.rb
CHANGED
@@ -5,7 +5,7 @@ require 'active_support/concern'
|
|
5
5
|
require 'odata'
|
6
6
|
|
7
7
|
require 'odata/model/version'
|
8
|
-
require 'odata/model/active_model'
|
8
|
+
require 'odata/model/active_model' if defined?(::ActiveModel)
|
9
9
|
require 'odata/model/configuration'
|
10
10
|
require 'odata/model/attributes'
|
11
11
|
require 'odata/model/persistence'
|
@@ -22,7 +22,7 @@ module OData
|
|
22
22
|
module Model
|
23
23
|
extend ActiveSupport::Concern
|
24
24
|
|
25
|
-
include OData::Model::ActiveModel
|
25
|
+
include OData::Model::ActiveModel if defined?(::ActiveModel)
|
26
26
|
include OData::Model::Configuration
|
27
27
|
include OData::Model::Attributes
|
28
28
|
include OData::Model::Persistence
|
data/odata-model.gemspec
CHANGED
@@ -24,9 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
26
26
|
|
27
|
+
spec.add_development_dependency 'activemodel', '>= 3.0.0'
|
28
|
+
|
27
29
|
spec.add_dependency 'odata', '~> 0.5'
|
28
30
|
spec.add_dependency 'activesupport', '>= 3.0.0'
|
29
|
-
spec.add_dependency 'activemodel', '>= 3.0.0'
|
30
31
|
|
31
32
|
spec.add_dependency 'slop', '~> 3.6.0'
|
32
33
|
end
|
@@ -5,6 +5,12 @@ describe OData::Model::QueryProxy do
|
|
5
5
|
let(:query_proxy) { OData::Model::QueryProxy.new(Product) }
|
6
6
|
let(:query_string) { subject.send(:query).to_s }
|
7
7
|
|
8
|
+
it 'allows limiting default selection to only selecting defined properties' do
|
9
|
+
query_proxy = OData::Model::QueryProxy.new(LimitedProduct)
|
10
|
+
query_string = query_proxy.send(:query).to_s
|
11
|
+
expect(query_string).to eq('Products?$select=ID,Name,Rating,Price')
|
12
|
+
end
|
13
|
+
|
8
14
|
it { expect(subject).to respond_to(:where) }
|
9
15
|
describe '#where' do
|
10
16
|
let(:subject) { query_proxy.where(:name) }
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,7 @@ OData::Service.open('http://services.odata.org/OData/OData.svc', name: 'ODataDem
|
|
20
20
|
|
21
21
|
require 'example_models/bare_model'
|
22
22
|
require 'example_models/odatademo_product'
|
23
|
+
require 'example_models/odatademo_limited_product'
|
23
24
|
require 'example_models/odatademo_person'
|
24
25
|
|
25
26
|
RSpec::Matchers.define :be_boolean do
|
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.
|
4
|
+
version: 0.4.0
|
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-07-
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,35 +81,35 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: activemodel
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
type: :
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: odata
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0.5'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '0.5'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: activesupport
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- lib/odata/model/version.rb
|
168
168
|
- odata-model.gemspec
|
169
169
|
- spec/example_models/bare_model.rb
|
170
|
+
- spec/example_models/odatademo_limited_product.rb
|
170
171
|
- spec/example_models/odatademo_person.rb
|
171
172
|
- spec/example_models/odatademo_product.rb
|
172
173
|
- spec/model/active_model_lint_spec.rb
|
@@ -202,6 +203,7 @@ specification_version: 4
|
|
202
203
|
summary: An ActiveModel mapping layer for the OData gem
|
203
204
|
test_files:
|
204
205
|
- spec/example_models/bare_model.rb
|
206
|
+
- spec/example_models/odatademo_limited_product.rb
|
205
207
|
- spec/example_models/odatademo_person.rb
|
206
208
|
- spec/example_models/odatademo_product.rb
|
207
209
|
- spec/model/active_model_lint_spec.rb
|