Sha256: 98d08e1808c7d62cd19b32e4cc44f884a2d6bbbe2ec8ca80c5fcb6d6194f1f86
Contents?: true
Size: 880 Bytes
Versions: 5
Compression:
Stored size: 880 Bytes
Contents
module OData4 module Properties # Defines the Boolean OData4 type. class Boolean < OData4::Property # Returns the property value, properly typecast # @return [Boolean, nil] def value if (@value.nil? || @value.empty?) && allows_nil? nil else (@value == 'true' || @value == '1') end end # Sets the property value # @params new_value [Boolean] def value=(new_value) validate(new_value) @value = new_value.to_s end # The OData4 type name def type 'Edm.Boolean' end private 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems