Class: OdataDuty::EntityType
Defined Under Namespace
Classes: Metadata
Instance Attribute Summary
Attributes inherited from ComplexType
#object, #od_context
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ComplexType
#initialize, properties, property
Class Method Details
39
40
41
|
# File 'lib/odata_duty/entity_type.rb', line 39
def self.__metadata
Metadata.new(self)
end
|
._defined_at_ ⇒ Object
68
69
70
|
# File 'lib/odata_duty/entity_type.rb', line 68
def self._defined_at_
const_source_location(to_s).join(':')
end
|
.int_mapper(context, selected:) ⇒ Object
56
57
58
59
60
|
# File 'lib/odata_duty/entity_type.rb', line 56
def self.int_mapper(context, selected:)
MapperBuilder.build(self, selected: selected) do |result, obj|
result['@odata.id'] = "#{context.current.fetch('odata_url_base')}(#{obj.id})"
end
end
|
.mapper(context, selected:) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/odata_duty/entity_type.rb', line 47
def self.mapper(context, selected:)
context.current['odata_url_base'] ||= context.od_full_url(context.endpoint.url)
if property_refs.first.raw_type == EdmInt64
int_mapper(context, selected: selected)
else
string_mapper(context, selected: selected)
end
end
|
.property_ref(*args, **kwargs) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/odata_duty/entity_type.rb', line 9
def self.property_ref(*args, **kwargs)
kwargs[:mutability] = :computed unless kwargs.key?(:mutability) || kwargs.key?(:computed)
property(*args, nullable: false, **kwargs).tap do |property|
raise 'Multiple Property Reference not yet supported' if property_refs.size.positive?
property_refs << property
end
end
|
.property_refs ⇒ Object
5
6
7
|
# File 'lib/odata_duty/entity_type.rb', line 5
def self.property_refs
@property_refs ||= []
end
|
.string_mapper(context, selected:) ⇒ Object
62
63
64
65
66
|
# File 'lib/odata_duty/entity_type.rb', line 62
def self.string_mapper(context, selected:)
MapperBuilder.build(self, selected: selected) do |result, obj|
result['@odata.id'] = "#{context.current.fetch('odata_url_base')}('#{obj.id}')"
end
end
|
Instance Method Details
#od_endpoint ⇒ Object
43
44
45
|
# File 'lib/odata_duty/entity_type.rb', line 43
def od_endpoint
od_context.endpoint
end
|