@private
# File lib/aws/record/attributes.rb, line 147 def self.allow_set? true end
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 138 def self.serialize string, options = {} unless string.is_a?(String) msg = "expected a String value, got #{string.class}" raise ArgumentError, msg end string end
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] 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 124 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