class DataTypes::Int32

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method DataTypes::BaseType::new
# File lib/active_model_serializers_binary/data_types.rb, line 46
def initialize(options = {})
  super options.merge :bit_length => 32, :sign => :signed
end

Public Instance Methods

dump(value=nil) click to toggle source
# File lib/active_model_serializers_binary/data_types.rb, line 50
def dump(value=nil)
  before_dump( value )
  if @endianess == :big
    @raw_value = @value.pack('l>*').unpack('C*')
  else
    @raw_value = @value.pack('l<*').unpack('C*')
  end
end
load(raw_value) click to toggle source
# File lib/active_model_serializers_binary/data_types.rb, line 59
def load(raw_value)
  if @endianess == :big
    self.value = check_raw_value(raw_value).pack('C*').unpack('l>*') if !value.nil?
  else
    self.value = check_raw_value(raw_value).pack('C*').unpack('l<*') if !value.nil?
  end
  after_load
end