Class: OData::Property
- Inherits:
-
Object
- Object
- OData::Property
- Defined in:
- lib/odata/property.rb
Overview
OData::Property represents an abstract property, defining the basic interface and required methods, with some default implementations. All supported property types should be implemented under the OData::Properties namespace.
Direct Known Subclasses
OData::Properties::Binary, OData::Properties::Boolean, OData::Properties::DateTime, OData::Properties::DateTimeOffset, OData::Properties::Decimal, OData::Properties::Float, OData::Properties::GeographyPoint, OData::Properties::Guid, OData::Properties::Integer, OData::Properties::String, OData::Properties::Time
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The property’s name.
-
#value ⇒ Object
The property’s value.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Provides for value-based equality checking.
-
#allows_nil? ⇒ Boolean
Whether the property permits a nil value.
-
#concurrency_mode ⇒ String
The configured concurrency mode for the property.
-
#initialize(name, value, options = {}) ⇒ Property
constructor
Default intialization for a property with a name, value and options.
-
#to_xml(xml_builder) ⇒ Object
Returns the XML representation of the property to the supplied XML builder.
-
#type ⇒ Object
Abstract implementation, should return property type, based on OData::Service metadata in proper implementation.
-
#url_value ⇒ String
Value to be used in URLs.
-
#xml_value ⇒ String
Value to be used in XML.
Constructor Details
#initialize(name, value, options = {}) ⇒ Property
Default intialization for a property with a name, value and options.
16 17 18 19 20 |
# File 'lib/odata/property.rb', line 16 def initialize(name, value, = {}) @name = name.to_s @value = value.nil? ? nil : value.to_s @options = .merge() end |
Instance Attribute Details
#name ⇒ Object (readonly)
The property’s name
8 9 10 |
# File 'lib/odata/property.rb', line 8 def name @name end |
#value ⇒ Object
The property’s value
10 11 12 |
# File 'lib/odata/property.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
Provides for value-based equality checking.
32 33 34 |
# File 'lib/odata/property.rb', line 32 def ==(other) self.value == other.value end |
#allows_nil? ⇒ Boolean
Whether the property permits a nil value.
38 39 40 |
# File 'lib/odata/property.rb', line 38 def allows_nil? @allows_nil ||= [:allows_nil] end |
#concurrency_mode ⇒ String
The configured concurrency mode for the property.
44 45 46 |
# File 'lib/odata/property.rb', line 44 def concurrency_mode @concurrecy_mode ||= [:concurrency_mode] end |
#to_xml(xml_builder) ⇒ Object
Returns the XML representation of the property to the supplied XML builder.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/odata/property.rb', line 63 def to_xml(xml_builder) attributes = { 'metadata:type' => type, } if value.nil? attributes['metadata:null'] = 'true' xml_builder['data'].send(name.to_sym, attributes) else xml_builder['data'].send(name.to_sym, attributes, xml_value) end end |
#type ⇒ Object
Abstract implementation, should return property type, based on OData::Service metadata in proper implementation.
25 26 27 |
# File 'lib/odata/property.rb', line 25 def type raise NotImplementedError end |
#url_value ⇒ String
Value to be used in URLs.
56 57 58 |
# File 'lib/odata/property.rb', line 56 def url_value value end |
#xml_value ⇒ String
Value to be used in XML.
50 51 52 |
# File 'lib/odata/property.rb', line 50 def xml_value value end |