Sha256: db25e949ce2bc9d50ce897df6bf45c2d92ec2e87edb28f9aedb8aa36f2b97403
Contents?: true
Size: 884 Bytes
Versions: 1
Compression:
Stored size: 884 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) raise ArgumentError, 'Value is outside accepted range: true or false' end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
odata4-0.7.0 | lib/odata4/properties/boolean.rb |