def typecast_attributes
    @attributes.each_pair do |name,value|
      # skip primary key columns
      # ajay Singh --> skip the loop if attribute is null (!name.present?)
      next if (name == "id") or (!name.present?)
      attr_type = attr_type_for(name)
      
      # empty attributes should stay empty (e.g. an empty int field shouldn't be typecast as 0)
      if [:datetime, :datetimecombo, :int].include? attr_type && (value.nil? || value == '')
        @attributes[name] = nil
        next
      end
      
      case attr_type
      when :bool
        @attributes[name] = (value == "1")
      when :datetime, :datetimecombo
        begin
          @attributes[name] = DateTime.parse(value)
        rescue
          @attributes[name] = value
        end
      when :int
        @attributes[name] = value.to_i
      end
    end
    @attributes
  end
def typecast_attributes
    @attributes.each_pair do |name,value|
      # skip primary key columns
      # ajay Singh --> skip the loop if attribute is null (!name.present?)
      next if (name == "id") or (!name.present?)
      attr_type = attr_type_for(name)
      
      # empty attributes should stay empty (e.g. an empty int field shouldn't be typecast as 0)
      if [:datetime, :datetimecombo, :int].include? attr_type && (value.nil? || value == '')
        @attributes[name] = nil
        next
      end
      
      case attr_type
      when :bool
        @attributes[name] = (value == "1")
      when :datetime, :datetimecombo
        begin
          @attributes[name] = DateTime.parse(value)
        rescue
          @attributes[name] = value
        end
      when :int
        @attributes[name] = value.to_i
      end
    end
    @attributes
  end
Attempts to typecast each attribute based on the module field type