class AWS::Record::Attributes::IntegerAttr
Public Class Methods
allow_set?()
click to toggle source
@api private
# File lib/aws/record/attributes.rb, line 224 def self.allow_set? true end
serialize(integer, options = {})
click to toggle source
Returns a serialized representation of the integer value suitable for storing in SimpleDB.
attribute.serialize(123) #=> '123'
@param [Integer] integer The number to serialize. @param [Hash] options @return [String] A serialized representation of the integer.
# File lib/aws/record/attributes.rb, line 219 def self.serialize integer, options = {} expect(Integer, integer) { integer } end
type_cast(raw_value, options = {})
click to toggle source
Returns value cast to an integer. Empty strings are cast to nil by default. Type casting is done by calling to_i on the value.
int_attribute.type_cast('123') #=> 123 int_attribute.type_cast('') #=> nil
@param [Mixed] raw_value The value to type cast to an integer. @return [Integer,nil] Returns the type casted integer or nil
# File lib/aws/record/attributes.rb, line 198 def self.type_cast raw_value, options = {} case raw_value when nil then nil when '' then nil when Integer then raw_value else raw_value.respond_to?(:to_i) ? raw_value.to_i : raw_value.to_s.to_i end end