Refactor Decimal#cast_value method