class AWS::Record::Attributes::StringAttr
Public Class Methods
allow_set?()
click to toggle source
@api private
# File lib/aws/record/attributes.rb, line 151 def self.allow_set? true end
serialize(string, options = {})
click to toggle source
Returns a serialized representation of the string value suitable for storing in SimpleDB. @param [String] string @param [Hash] options @return [String] The serialized string.
# File lib/aws/record/attributes.rb, line 142 def self.serialize string, options = {} unless string.is_a?(String) msg = "expected a String value, got #{string.class}" raise ArgumentError, msg end string end
type_cast(raw_value, options = {})
click to toggle source
Returns the value cast to a string. Empty strings are returned as nil by default. Type casting is done by calling to_s on the value.
string_attr.type_cast(123) # => '123' string_attr.type_cast('') # => nil string_attr.type_cast('', :preserve_empty_strings => true) # => ''
@param [Mixed] raw_value @param [Hash] options @option options [Boolean] :preserve_empty_strings (false) When true,
empty strings are preserved and not cast to nil.
@return [String,nil] The type casted value.
# File lib/aws/record/attributes.rb, line 128 def self.type_cast raw_value, options = {} case raw_value when nil then nil when '' then options[:preserve_empty_strings] ? '' : nil when String then raw_value else raw_value.to_s end end