Class: OData::Properties::String

Inherits:
OData::Property show all
Defined in:
lib/odata/properties/string.rb

Overview

Defines the String OData type.

Instance Attribute Summary

Attributes inherited from OData::Property

#name

Instance Method Summary collapse

Methods inherited from OData::Property

#==, #allows_nil?, #concurrency_mode, #initialize, #to_xml, #xml_value

Constructor Details

This class inherits a constructor from OData::Property

Instance Method Details

#default_valueObject

The default value for the property



44
45
46
# File 'lib/odata/properties/string.rb', line 44

def default_value
  options[:default_value]
end

#has_default_value?Boolean

Does the property have a default value

Returns:



39
40
41
# File 'lib/odata/properties/string.rb', line 39

def has_default_value?
  not(options[:default_value].nil?)
end

#is_unicode?Boolean

Is the property value Unicode encoded

Returns:



34
35
36
# File 'lib/odata/properties/string.rb', line 34

def is_unicode?
  options[:unicode]
end

#typeObject

The OData type name



29
30
31
# File 'lib/odata/properties/string.rb', line 29

def type
  'Edm.String'
end

#url_valueString

Value to be used in URLs.

Returns:



24
25
26
# File 'lib/odata/properties/string.rb', line 24

def url_value
  "'#{value}'"
end

#valueString?

Returns the property value, properly typecast

Returns:



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

def value
  if (@value.nil? || @value.empty?) && allows_nil?
    nil
  else
    encode_value(@value)
  end
end

#value=(new_value) ⇒ Object

Sets the property value



17
18
19
20
# File 'lib/odata/properties/string.rb', line 17

def value=(new_value)
  validate(new_value)
  @value = new_value.nil? ? nil : encode_value(new_value.to_s)
end