Class: OData::EnumType
Instance Attribute Summary collapse
-
#members ⇒ Object
readonly
Returns the value of attribute members.
Attributes inherited from Type
Instance Method Summary collapse
- #coerce(value) ⇒ Object
-
#initialize(options = {}) ⇒ EnumType
constructor
A new instance of EnumType.
- #type ⇒ Object
- #valid_value?(value) ⇒ Boolean
Methods inherited from Type
Constructor Details
#initialize(options = {}) ⇒ EnumType
Returns a new instance of EnumType.
5 6 7 8 |
# File 'lib/odata/types/enum_type.rb', line 5 def initialize(={}) super @members = [:members] end |
Instance Attribute Details
#members ⇒ Object (readonly)
Returns the value of attribute members.
3 4 5 |
# File 'lib/odata/types/enum_type.rb', line 3 def members @members end |
Instance Method Details
#coerce(value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/odata/types/enum_type.rb', line 18 def coerce(value) if value && value.is_a?(Integer) member = @members.find { |m| m[:value] == value } member && member[:name] else super end end |
#type ⇒ Object
14 15 16 |
# File 'lib/odata/types/enum_type.rb', line 14 def type name end |
#valid_value?(value) ⇒ Boolean
10 11 12 |
# File 'lib/odata/types/enum_type.rb', line 10 def valid_value?(value) member_names.include?(value) || member_values.include?(value) end |