odata-model 0.4.0 → 0.4.1
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/CHANGELOG.md +4 -0
- data/lib/odata/model/attributes.rb +12 -0
- data/lib/odata/model/configuration.rb +1 -0
- data/lib/odata/model/version.rb +1 -1
- data/odata-model.gemspec +3 -4
- data/spec/model/property_defaults_spec.rb +13 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3848c44d4405013bdf8759766f32d0d7eed788
|
4
|
+
data.tar.gz: 514c663ad8f2fe30635444b96eb38c00208dffbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d82ecb0dec062b31c58eeb57698150e9d04a65eb766639bfa7f416fdb4813641a4b359d92693e5782f492bc1711164240a75ca093f7cb56602fdc6786c7002
|
7
|
+
data.tar.gz: 26535f3f30778fea0a13daf60bee9d17c3e5192ab0ef7973c087736f36304505fae8e998fdb7dd71444acb5e3f5d21e6cf3fcfc69f985aa2b0d48d47ec1038ed
|
data/CHANGELOG.md
CHANGED
@@ -36,6 +36,7 @@ module OData
|
|
36
36
|
def property(literal_name, options = {})
|
37
37
|
attribute_name = (options[:as] || literal_name.to_s.underscore).to_sym
|
38
38
|
|
39
|
+
validate_attribute(literal_name)
|
39
40
|
register_attribute(attribute_name, literal_name, options)
|
40
41
|
create_accessors(attribute_name)
|
41
42
|
|
@@ -80,6 +81,17 @@ module OData
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
84
|
+
# Validates the existence of the supplied attribute on the relevant
|
85
|
+
# Entity.
|
86
|
+
# @param property_name [to_s]
|
87
|
+
# @api private
|
88
|
+
def validate_attribute(property_name)
|
89
|
+
valid_properties = odata_service.properties_for(odata_entity_set.type)
|
90
|
+
unless valid_properties[property_name.to_s]
|
91
|
+
raise ArgumentError, "property #{property_name} does not exist for #{odata_entity_set.type} entity"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
83
95
|
# Registers a supplied attribute with its literal property name and any
|
84
96
|
# provided options.
|
85
97
|
# @return [nil]
|
data/lib/odata/model/version.rb
CHANGED
data/odata-model.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = OData::Model::VERSION
|
9
9
|
spec.authors = ['James Thompson']
|
10
10
|
spec.email = %w{james@buypd.com}
|
11
|
-
spec.summary = '
|
12
|
-
spec.description = 'A mapping layer for the OData gem that
|
11
|
+
spec.summary = 'A basic mapping layer for the OData gem'
|
12
|
+
spec.description = 'A mapping layer for the OData gem that can integrate with ActiveModel'
|
13
13
|
spec.homepage = 'https://github.com/ruby-odata/odata-model'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -23,10 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'simplecov', '~> 0.9.0'
|
24
24
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
26
|
-
|
27
26
|
spec.add_development_dependency 'activemodel', '>= 3.0.0'
|
28
27
|
|
29
|
-
spec.add_dependency 'odata', '~> 0.5'
|
28
|
+
spec.add_dependency 'odata', '~> 0.5.0'
|
30
29
|
spec.add_dependency 'activesupport', '>= 3.0.0'
|
31
30
|
|
32
31
|
spec.add_dependency 'slop', '~> 3.6.0'
|
@@ -18,5 +18,18 @@ describe OData::Model do
|
|
18
18
|
|
19
19
|
it { expect(Product.new).to respond_to(:attributes) }
|
20
20
|
it { expect(Product.new.attributes).to eq(attributes) }
|
21
|
+
|
22
|
+
it 'raises an error if the property does not exist on the entity' do
|
23
|
+
expect {
|
24
|
+
class InvalidProduct
|
25
|
+
include OData::Model
|
26
|
+
|
27
|
+
use_service 'ODataDemo'
|
28
|
+
for_entity 'Product'
|
29
|
+
|
30
|
+
property 'NonExistent'
|
31
|
+
end
|
32
|
+
}.to raise_error(ArgumentError, 'property NonExistent does not exist for Product entity')
|
33
|
+
end
|
21
34
|
end
|
22
35
|
end
|
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.
|
4
|
+
version: 0.4.1
|
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-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.5.0
|
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.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: activesupport
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 3.6.0
|
139
|
-
description: A mapping layer for the OData gem that
|
139
|
+
description: A mapping layer for the OData gem that can integrate with ActiveModel
|
140
140
|
email:
|
141
141
|
- james@buypd.com
|
142
142
|
executables:
|
@@ -200,7 +200,7 @@ rubyforge_project:
|
|
200
200
|
rubygems_version: 2.2.2
|
201
201
|
signing_key:
|
202
202
|
specification_version: 4
|
203
|
-
summary:
|
203
|
+
summary: A basic mapping layer for the OData gem
|
204
204
|
test_files:
|
205
205
|
- spec/example_models/bare_model.rb
|
206
206
|
- spec/example_models/odatademo_limited_product.rb
|