class OData4::Properties::Boolean

Defines the Boolean OData4 type.

Public Instance Methods

type() click to toggle source

The OData4 type name

# File lib/odata4/properties/boolean.rb, line 23
def type
  'Edm.Boolean'
end
value() click to toggle source

Returns the property value, properly typecast @return [Boolean, nil]

# 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) click to toggle source

Sets the property value @params new_value [Boolean]

# File lib/odata4/properties/boolean.rb, line 17
def value=(new_value)
  validate(new_value)
  @value = new_value.to_s
end

Private Instance Methods

validate(value) click to toggle source
# File lib/odata4/properties/boolean.rb, line 29
def validate(value)
  return if value.nil? && allows_nil?
  unless [0,1,'0','1','true','false',true,false].include?(value)
    validation_error 'Value is outside accepted range: true or false'
  end
end