Class: OData4::Properties::Boolean

Inherits:
OData4::Property show all
Defined in:
lib/odata4/properties/boolean.rb

Overview

Defines the Boolean OData4 type.

Instance Attribute Summary

Attributes inherited from OData4::Property

#name, #options

Instance Method Summary collapse

Methods inherited from OData4::Property

#==, #allows_nil?, #concurrency_mode, from_xml, #initialize, #json_value, #strict?, #to_xml, #url_value, #xml_value

Constructor Details

This class inherits a constructor from OData4::Property

Instance Method Details

#typeObject

The OData4 type name



23
24
25
# File 'lib/odata4/properties/boolean.rb', line 23

def type
  'Edm.Boolean'
end

#valueBoolean?

Returns the property value, properly typecast

Returns:



7
8
9
10
11
12
13
# File 'lib/odata4/properties/boolean.rb', line 7

def value
  if (@value.nil? || @value.empty?) && allows_nil?
    nil
  else
    (@value == 'true' || @value == '1')
  end
end

#value=(new_value) ⇒ Object

Sets the property value



17
18
19
20
# File 'lib/odata4/properties/boolean.rb', line 17

def value=(new_value)
  validate(new_value)
  @value = new_value.to_s
end