microsoft_graph 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -11
- data/.rspec +2 -2
- data/.travis.yml +4 -4
- data/Gemfile +4 -4
- data/LICENSE +10 -10
- data/README.md +99 -98
- data/Rakefile +7 -7
- data/data/metadata_v1.0.xml +1686 -1686
- data/integration_spec/integration_spec_helper.rb +18 -18
- data/integration_spec/live_spec.rb +180 -180
- data/lib/microsoft_graph.rb +35 -35
- data/lib/microsoft_graph/base.rb +110 -110
- data/lib/microsoft_graph/base_entity.rb +152 -152
- data/lib/microsoft_graph/cached_metadata_directory.rb +3 -3
- data/lib/microsoft_graph/class_builder.rb +217 -217
- data/lib/microsoft_graph/collection.rb +95 -95
- data/lib/microsoft_graph/collection_association.rb +232 -232
- data/lib/microsoft_graph/errors.rb +6 -6
- data/lib/microsoft_graph/version.rb +3 -3
- data/lib/odata.rb +49 -49
- data/lib/odata/entity_set.rb +20 -20
- data/lib/odata/errors.rb +18 -18
- data/lib/odata/navigation_property.rb +30 -30
- data/lib/odata/operation.rb +17 -17
- data/lib/odata/property.rb +38 -38
- data/lib/odata/request.rb +49 -49
- data/lib/odata/service.rb +279 -279
- data/lib/odata/singleton.rb +20 -20
- data/lib/odata/type.rb +25 -25
- data/lib/odata/types/collection_type.rb +30 -30
- data/lib/odata/types/complex_type.rb +19 -19
- data/lib/odata/types/entity_type.rb +33 -33
- data/lib/odata/types/enum_type.rb +37 -37
- data/lib/odata/types/primitive_type.rb +12 -12
- data/lib/odata/types/primitive_types/binary_type.rb +15 -15
- data/lib/odata/types/primitive_types/boolean_type.rb +15 -15
- data/lib/odata/types/primitive_types/date_time_offset_type.rb +15 -15
- data/lib/odata/types/primitive_types/date_type.rb +23 -23
- data/lib/odata/types/primitive_types/double_type.rb +16 -16
- data/lib/odata/types/primitive_types/guid_type.rb +24 -24
- data/lib/odata/types/primitive_types/int_16_type.rb +19 -19
- data/lib/odata/types/primitive_types/int_32_type.rb +15 -15
- data/lib/odata/types/primitive_types/int_64_type.rb +15 -15
- data/lib/odata/types/primitive_types/stream_type.rb +15 -15
- data/lib/odata/types/primitive_types/string_type.rb +15 -15
- data/microsoft_graph-0.1.2.gem +0 -0
- data/microsoft_graph.gemspec +31 -31
- data/tasks/update_metadata.rb +17 -17
- metadata +6 -6
- data/microsoft_graph-0.1.0.gem +0 -0
data/lib/microsoft_graph/base.rb
CHANGED
@@ -1,110 +1,110 @@
|
|
1
|
-
class MicrosoftGraph
|
2
|
-
class Base
|
3
|
-
|
4
|
-
def initialize(options = {})
|
5
|
-
@cached_navigation_property_values = {}
|
6
|
-
@cached_property_values = {}
|
7
|
-
if options[:attributes]
|
8
|
-
initialize_serialized_properties(options[:attributes], options[:persisted])
|
9
|
-
end
|
10
|
-
@dirty = ! options[:persisted]
|
11
|
-
@dirty_properties = if @dirty
|
12
|
-
@cached_property_values.keys.inject({}) do |result, key|
|
13
|
-
result[key] = true
|
14
|
-
result
|
15
|
-
end
|
16
|
-
else
|
17
|
-
{}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def properties
|
22
|
-
{}
|
23
|
-
end
|
24
|
-
|
25
|
-
def odata_type
|
26
|
-
self.class.const_get("ODATA_TYPE").name
|
27
|
-
end
|
28
|
-
|
29
|
-
def as_json(options = {})
|
30
|
-
(if options[:only]
|
31
|
-
@cached_property_values.select { |key,v| options[:only].include? key }
|
32
|
-
elsif options[:except]
|
33
|
-
@cached_property_values.reject { |key,v| options[:except].include? key }
|
34
|
-
else
|
35
|
-
@cached_property_values
|
36
|
-
end).inject({}) do |result, (k,v)|
|
37
|
-
k = OData.convert_to_camel_case(k) if options[:convert_to_camel_case]
|
38
|
-
result[k.to_s] = v.respond_to?(:as_json) ? v.as_json(options) : v
|
39
|
-
result
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def to_json(options = {})
|
44
|
-
as_json(options).to_json
|
45
|
-
end
|
46
|
-
|
47
|
-
def dirty?
|
48
|
-
@dirty || @cached_property_values.any? { |key, value|
|
49
|
-
value.respond_to?(:dirty?) && value.dirty?
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
def mark_clean
|
54
|
-
@dirty = false
|
55
|
-
@dirty_properties = {}
|
56
|
-
@cached_property_values.each { |key, value|
|
57
|
-
value.respond_to?(:mark_clean) && value.mark_clean
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def get(property_name)
|
64
|
-
if properties[property_name].collection?
|
65
|
-
@cached_property_values[property_name] ||= Collection.new(properties[property_name].type)
|
66
|
-
else
|
67
|
-
@cached_property_values[property_name]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def set(property_name, value)
|
72
|
-
property = properties[property_name]
|
73
|
-
|
74
|
-
raise NonNullableError unless property.nullable_match?(value)
|
75
|
-
if property.collection?
|
76
|
-
raise TypeError unless value.all? { |v| property.collection_type_match?(v) }
|
77
|
-
@cached_property_values[property_name] = Collection.new(property.type, value)
|
78
|
-
else
|
79
|
-
raise TypeError unless property.type_match?(value)
|
80
|
-
@cached_property_values[property_name] = property.coerce_to_type(value)
|
81
|
-
end
|
82
|
-
@dirty = true
|
83
|
-
@dirty_properties[property_name] = true
|
84
|
-
end
|
85
|
-
|
86
|
-
def initialize_serialized_properties(raw_attributes, from_server = false)
|
87
|
-
unless raw_attributes.respond_to? :keys
|
88
|
-
raise TypeError.new("Cannot initialize #{self.class} with attributes: #{raw_attributes.inspect}")
|
89
|
-
end
|
90
|
-
attributes = OData.convert_keys_to_snake_case(raw_attributes)
|
91
|
-
properties.each do |property_key, property|
|
92
|
-
if attributes.keys.include?(property_key.to_s)
|
93
|
-
value = attributes[property_key.to_s]
|
94
|
-
@cached_property_values[property_key] =
|
95
|
-
if property.collection?
|
96
|
-
Collection.new(property.type, value)
|
97
|
-
elsif klass = MicrosoftGraph::ClassBuilder.get_namespaced_class(property.type.name)
|
98
|
-
klass.new(attributes: value)
|
99
|
-
else
|
100
|
-
if from_server && ! property.type_match?(value) && OData::EnumType === property.type
|
101
|
-
value.to_s
|
102
|
-
else
|
103
|
-
property.coerce_to_type(value)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
1
|
+
class MicrosoftGraph
|
2
|
+
class Base
|
3
|
+
|
4
|
+
def initialize(options = {})
|
5
|
+
@cached_navigation_property_values = {}
|
6
|
+
@cached_property_values = {}
|
7
|
+
if options[:attributes]
|
8
|
+
initialize_serialized_properties(options[:attributes], options[:persisted])
|
9
|
+
end
|
10
|
+
@dirty = ! options[:persisted]
|
11
|
+
@dirty_properties = if @dirty
|
12
|
+
@cached_property_values.keys.inject({}) do |result, key|
|
13
|
+
result[key] = true
|
14
|
+
result
|
15
|
+
end
|
16
|
+
else
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def properties
|
22
|
+
{}
|
23
|
+
end
|
24
|
+
|
25
|
+
def odata_type
|
26
|
+
self.class.const_get("ODATA_TYPE").name
|
27
|
+
end
|
28
|
+
|
29
|
+
def as_json(options = {})
|
30
|
+
(if options[:only]
|
31
|
+
@cached_property_values.select { |key,v| options[:only].include? key }
|
32
|
+
elsif options[:except]
|
33
|
+
@cached_property_values.reject { |key,v| options[:except].include? key }
|
34
|
+
else
|
35
|
+
@cached_property_values
|
36
|
+
end).inject({}) do |result, (k,v)|
|
37
|
+
k = OData.convert_to_camel_case(k) if options[:convert_to_camel_case]
|
38
|
+
result[k.to_s] = v.respond_to?(:as_json) ? v.as_json(options) : v
|
39
|
+
result
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_json(options = {})
|
44
|
+
as_json(options).to_json
|
45
|
+
end
|
46
|
+
|
47
|
+
def dirty?
|
48
|
+
@dirty || @cached_property_values.any? { |key, value|
|
49
|
+
value.respond_to?(:dirty?) && value.dirty?
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def mark_clean
|
54
|
+
@dirty = false
|
55
|
+
@dirty_properties = {}
|
56
|
+
@cached_property_values.each { |key, value|
|
57
|
+
value.respond_to?(:mark_clean) && value.mark_clean
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def get(property_name)
|
64
|
+
if properties[property_name].collection?
|
65
|
+
@cached_property_values[property_name] ||= Collection.new(properties[property_name].type)
|
66
|
+
else
|
67
|
+
@cached_property_values[property_name]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def set(property_name, value)
|
72
|
+
property = properties[property_name]
|
73
|
+
|
74
|
+
raise NonNullableError unless property.nullable_match?(value)
|
75
|
+
if property.collection?
|
76
|
+
raise TypeError unless value.all? { |v| property.collection_type_match?(v) }
|
77
|
+
@cached_property_values[property_name] = Collection.new(property.type, value)
|
78
|
+
else
|
79
|
+
raise TypeError unless property.type_match?(value)
|
80
|
+
@cached_property_values[property_name] = property.coerce_to_type(value)
|
81
|
+
end
|
82
|
+
@dirty = true
|
83
|
+
@dirty_properties[property_name] = true
|
84
|
+
end
|
85
|
+
|
86
|
+
def initialize_serialized_properties(raw_attributes, from_server = false)
|
87
|
+
unless raw_attributes.respond_to? :keys
|
88
|
+
raise TypeError.new("Cannot initialize #{self.class} with attributes: #{raw_attributes.inspect}")
|
89
|
+
end
|
90
|
+
attributes = OData.convert_keys_to_snake_case(raw_attributes)
|
91
|
+
properties.each do |property_key, property|
|
92
|
+
if attributes.keys.include?(property_key.to_s)
|
93
|
+
value = attributes[property_key.to_s]
|
94
|
+
@cached_property_values[property_key] =
|
95
|
+
if property.collection?
|
96
|
+
Collection.new(property.type, value)
|
97
|
+
elsif klass = MicrosoftGraph::ClassBuilder.get_namespaced_class(property.type.name)
|
98
|
+
klass.new(attributes: value)
|
99
|
+
else
|
100
|
+
if from_server && ! property.type_match?(value) && OData::EnumType === property.type
|
101
|
+
value.to_s
|
102
|
+
else
|
103
|
+
property.coerce_to_type(value)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -1,152 +1,152 @@
|
|
1
|
-
class MicrosoftGraph
|
2
|
-
class BaseEntity < Base
|
3
|
-
|
4
|
-
attr_accessor :graph
|
5
|
-
attr_accessor :parent
|
6
|
-
|
7
|
-
def initialize(options = {})
|
8
|
-
@resource_name = options[:resource_name]
|
9
|
-
@parent = options[:parent] || options[:graph]
|
10
|
-
@graph = options[:graph] || parent && parent.graph
|
11
|
-
@navigation_property_name = options[:navigation_property_name]
|
12
|
-
@persisted = options[:persisted] || false
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
def parental_chain
|
17
|
-
if parent && parent.respond_to?(:parental_chain)
|
18
|
-
parent.parental_chain.concat([parent])
|
19
|
-
else
|
20
|
-
[parent]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def containing_navigation_property(type_name)
|
25
|
-
candidate_navigation_properties = navigation_properties.values.select do |navigation_property|
|
26
|
-
navigation_property.collection? && navigation_property.type.name == "Collection(#{type_name})"
|
27
|
-
end
|
28
|
-
candidate_navigation_properties.sort { |a, b|
|
29
|
-
a_index = type_name.downcase.index(a.name[0..-2].downcase) || 0
|
30
|
-
b_index = type_name.downcase.index(b.name[0..-2].downcase) || 0
|
31
|
-
a_index <=> b_index
|
32
|
-
}.last
|
33
|
-
end
|
34
|
-
|
35
|
-
def path
|
36
|
-
containing_navigation_property_name = nil
|
37
|
-
owning_ancestor = parental_chain.find do |ancestor|
|
38
|
-
unless MicrosoftGraph::CollectionAssociation === ancestor
|
39
|
-
containing_navigation_property = ancestor.containing_navigation_property(odata_type)
|
40
|
-
containing_navigation_property && containing_navigation_property_name = containing_navigation_property.name
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if owning_ancestor && @cached_property_values[:id]
|
45
|
-
[owning_ancestor.path, containing_navigation_property_name, @cached_property_values[:id]].compact.join("/")
|
46
|
-
else
|
47
|
-
@resource_name
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def fetch
|
52
|
-
@persisted = true
|
53
|
-
initialize_serialized_properties(graph.service.get(path)[:attributes])
|
54
|
-
end
|
55
|
-
|
56
|
-
def persisted?
|
57
|
-
@persisted
|
58
|
-
end
|
59
|
-
|
60
|
-
def delete!
|
61
|
-
if persisted?
|
62
|
-
@persisted = false
|
63
|
-
graph.service.delete(path)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def reload!
|
68
|
-
@dirty_properties.keys.each do |dirty_property|
|
69
|
-
@cached_property_values[dirty_property] = nil
|
70
|
-
end
|
71
|
-
mark_clean
|
72
|
-
fetch if persisted?
|
73
|
-
end
|
74
|
-
|
75
|
-
def save!
|
76
|
-
raise NoAssociationError unless parent
|
77
|
-
raise_no_graph_error! unless graph
|
78
|
-
if persisted?
|
79
|
-
graph.service.patch(path, to_json(only: @dirty_properties.keys, convert_to_camel_case: true))
|
80
|
-
else
|
81
|
-
initialize_serialized_properties(
|
82
|
-
graph.service.post(parent.path, to_json(convert_to_camel_case: true))
|
83
|
-
)
|
84
|
-
@persisted = true
|
85
|
-
end
|
86
|
-
mark_clean
|
87
|
-
true
|
88
|
-
end
|
89
|
-
|
90
|
-
def save
|
91
|
-
save!
|
92
|
-
rescue OData::HTTPError
|
93
|
-
false
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def raise_no_graph_error!
|
99
|
-
raise NoGraphError.new("#{self.class}#graph must be a MicrosoftGraph instance to make network requests.")
|
100
|
-
end
|
101
|
-
|
102
|
-
def get(property_name)
|
103
|
-
if uncached_property?(property_name) && graph
|
104
|
-
initialize_serialized_properties(graph.service.get(path, property_name.to_s)[:attributes], true)
|
105
|
-
super
|
106
|
-
else
|
107
|
-
super
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def get_navigation_property(navigation_property_name)
|
112
|
-
raise_no_graph_error! unless graph
|
113
|
-
navigation_property = navigation_properties[navigation_property_name]
|
114
|
-
if navigation_property.collection?
|
115
|
-
@cached_navigation_property_values[navigation_property_name] ||=
|
116
|
-
CollectionAssociation.new(
|
117
|
-
graph: graph,
|
118
|
-
type: navigation_properties[navigation_property_name].type,
|
119
|
-
resource_name: OData.convert_to_camel_case(navigation_property_name.to_s),
|
120
|
-
parent: self
|
121
|
-
)
|
122
|
-
else
|
123
|
-
@cached_navigation_property_values[navigation_property_name] ||=
|
124
|
-
if response = graph.service.get("#{path}/#{OData.convert_to_camel_case(navigation_property_name.to_s)}")
|
125
|
-
type = graph.service.get_type_for_odata_response(response[:attributes]) || navigation_property.type
|
126
|
-
klass = ClassBuilder.get_namespaced_class(type.name)
|
127
|
-
klass.new(
|
128
|
-
graph: graph,
|
129
|
-
parent: self,
|
130
|
-
attributes: response[:attributes],
|
131
|
-
persisted: true,
|
132
|
-
navigation_property_name: navigation_property_name.to_s
|
133
|
-
)
|
134
|
-
else
|
135
|
-
nil
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def set_navigation_property(navigation_property_name, value)
|
141
|
-
navigation_property = navigation_properties[navigation_property_name]
|
142
|
-
raise TypeError unless navigation_property.type_match?(value)
|
143
|
-
value.parent = self
|
144
|
-
@cached_navigation_property_values[navigation_property_name] = value
|
145
|
-
end
|
146
|
-
|
147
|
-
def uncached_property?(property)
|
148
|
-
properties.keys.include?(property) && ! @cached_property_values.keys.include?(property)
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
1
|
+
class MicrosoftGraph
|
2
|
+
class BaseEntity < Base
|
3
|
+
|
4
|
+
attr_accessor :graph
|
5
|
+
attr_accessor :parent
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@resource_name = options[:resource_name]
|
9
|
+
@parent = options[:parent] || options[:graph]
|
10
|
+
@graph = options[:graph] || parent && parent.graph
|
11
|
+
@navigation_property_name = options[:navigation_property_name]
|
12
|
+
@persisted = options[:persisted] || false
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def parental_chain
|
17
|
+
if parent && parent.respond_to?(:parental_chain)
|
18
|
+
parent.parental_chain.concat([parent])
|
19
|
+
else
|
20
|
+
[parent]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def containing_navigation_property(type_name)
|
25
|
+
candidate_navigation_properties = navigation_properties.values.select do |navigation_property|
|
26
|
+
navigation_property.collection? && navigation_property.type.name == "Collection(#{type_name})"
|
27
|
+
end
|
28
|
+
candidate_navigation_properties.sort { |a, b|
|
29
|
+
a_index = type_name.downcase.index(a.name[0..-2].downcase) || 0
|
30
|
+
b_index = type_name.downcase.index(b.name[0..-2].downcase) || 0
|
31
|
+
a_index <=> b_index
|
32
|
+
}.last
|
33
|
+
end
|
34
|
+
|
35
|
+
def path
|
36
|
+
containing_navigation_property_name = nil
|
37
|
+
owning_ancestor = parental_chain.find do |ancestor|
|
38
|
+
unless MicrosoftGraph::CollectionAssociation === ancestor
|
39
|
+
containing_navigation_property = ancestor.containing_navigation_property(odata_type)
|
40
|
+
containing_navigation_property && containing_navigation_property_name = containing_navigation_property.name
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if owning_ancestor && @cached_property_values[:id]
|
45
|
+
[owning_ancestor.path, containing_navigation_property_name, @cached_property_values[:id]].compact.join("/")
|
46
|
+
else
|
47
|
+
@resource_name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch
|
52
|
+
@persisted = true
|
53
|
+
initialize_serialized_properties(graph.service.get(path)[:attributes])
|
54
|
+
end
|
55
|
+
|
56
|
+
def persisted?
|
57
|
+
@persisted
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete!
|
61
|
+
if persisted?
|
62
|
+
@persisted = false
|
63
|
+
graph.service.delete(path)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def reload!
|
68
|
+
@dirty_properties.keys.each do |dirty_property|
|
69
|
+
@cached_property_values[dirty_property] = nil
|
70
|
+
end
|
71
|
+
mark_clean
|
72
|
+
fetch if persisted?
|
73
|
+
end
|
74
|
+
|
75
|
+
def save!
|
76
|
+
raise NoAssociationError unless parent
|
77
|
+
raise_no_graph_error! unless graph
|
78
|
+
if persisted?
|
79
|
+
graph.service.patch(path, to_json(only: @dirty_properties.keys, convert_to_camel_case: true))
|
80
|
+
else
|
81
|
+
initialize_serialized_properties(
|
82
|
+
graph.service.post(parent.path, to_json(convert_to_camel_case: true))
|
83
|
+
)
|
84
|
+
@persisted = true
|
85
|
+
end
|
86
|
+
mark_clean
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def save
|
91
|
+
save!
|
92
|
+
rescue OData::HTTPError
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def raise_no_graph_error!
|
99
|
+
raise NoGraphError.new("#{self.class}#graph must be a MicrosoftGraph instance to make network requests.")
|
100
|
+
end
|
101
|
+
|
102
|
+
def get(property_name)
|
103
|
+
if uncached_property?(property_name) && graph
|
104
|
+
initialize_serialized_properties(graph.service.get(path, property_name.to_s)[:attributes], true)
|
105
|
+
super
|
106
|
+
else
|
107
|
+
super
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_navigation_property(navigation_property_name)
|
112
|
+
raise_no_graph_error! unless graph
|
113
|
+
navigation_property = navigation_properties[navigation_property_name]
|
114
|
+
if navigation_property.collection?
|
115
|
+
@cached_navigation_property_values[navigation_property_name] ||=
|
116
|
+
CollectionAssociation.new(
|
117
|
+
graph: graph,
|
118
|
+
type: navigation_properties[navigation_property_name].type,
|
119
|
+
resource_name: OData.convert_to_camel_case(navigation_property_name.to_s),
|
120
|
+
parent: self
|
121
|
+
)
|
122
|
+
else
|
123
|
+
@cached_navigation_property_values[navigation_property_name] ||=
|
124
|
+
if response = graph.service.get("#{path}/#{OData.convert_to_camel_case(navigation_property_name.to_s)}")
|
125
|
+
type = graph.service.get_type_for_odata_response(response[:attributes]) || navigation_property.type
|
126
|
+
klass = ClassBuilder.get_namespaced_class(type.name)
|
127
|
+
klass.new(
|
128
|
+
graph: graph,
|
129
|
+
parent: self,
|
130
|
+
attributes: response[:attributes],
|
131
|
+
persisted: true,
|
132
|
+
navigation_property_name: navigation_property_name.to_s
|
133
|
+
)
|
134
|
+
else
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def set_navigation_property(navigation_property_name, value)
|
141
|
+
navigation_property = navigation_properties[navigation_property_name]
|
142
|
+
raise TypeError unless navigation_property.type_match?(value)
|
143
|
+
value.parent = self
|
144
|
+
@cached_navigation_property_values[navigation_property_name] = value
|
145
|
+
end
|
146
|
+
|
147
|
+
def uncached_property?(property)
|
148
|
+
properties.keys.include?(property) && ! @cached_property_values.keys.include?(property)
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|