Class: OData::Property
- Inherits:
-
Object
- Object
- OData::Property
- Defined in:
- lib/odata/property.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #coerce_to_type(value) ⇒ Object
- #collection? ⇒ Boolean
- #collection_type_match?(value) ⇒ Boolean
-
#initialize(options = {}) ⇒ Property
constructor
A new instance of Property.
- #nullable_match?(value) ⇒ Boolean
- #type_match?(value) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Property
Returns a new instance of Property.
9 10 11 12 13 |
# File 'lib/odata/property.rb', line 9 def initialize( = {}) @name = [:name] @nullable = [:nullable] @type = [:type] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/odata/property.rb', line 5 def name @name end |
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
6 7 8 |
# File 'lib/odata/property.rb', line 6 def nullable @nullable end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/odata/property.rb', line 7 def type @type end |
Instance Method Details
#coerce_to_type(value) ⇒ Object
19 20 21 22 |
# File 'lib/odata/property.rb', line 19 def coerce_to_type(value) return nil if value.nil? type.coerce(value) end |
#collection? ⇒ Boolean
15 16 17 |
# File 'lib/odata/property.rb', line 15 def collection? OData::CollectionType === type end |
#collection_type_match?(value) ⇒ Boolean
24 25 26 27 |
# File 'lib/odata/property.rb', line 24 def collection_type_match?(value) collection = type collection.valid_value?(value) end |
#nullable_match?(value) ⇒ Boolean
33 34 35 |
# File 'lib/odata/property.rb', line 33 def nullable_match?(value) nullable || !value.nil? end |
#type_match?(value) ⇒ Boolean
29 30 31 |
# File 'lib/odata/property.rb', line 29 def type_match?(value) type.valid_value?(value) || (value.nil? && nullable) end |